94

theFanXY
ek-cai
Cccc
cgj7227

22小时前
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
int n;
cin >> n;

int cx = n / 2, cy = n / 2;
for (int i = 0; i < n; i ++)
{
for (int j = 0; j < n; j ++)
{
int d = abs(j - cx) + abs(i - cy); // 等同于abs(i - cx) + abs(j - cy);
if (d > n / 2) cout << " ";
else cout << "*";
}
cout << endl;
}
return 0;
}


22小时前
#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
while (n --)
{
int x;
cin >> x;
bool is_prime = true;
for (int i = 2; i * i <= x; i ++)
if (x % i == 0) is_prime = false;
if (is_prime) cout << x << " is prime" << endl;
else cout << x << " is not prime" << endl;
}

return 0;
}


22小时前
#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;

while(n -- )
{
int x;
cin >> x;
int sum = 0;
for (int i = 1; i * i <= x; i ++)
if (x % i == 0)
{
if (i < x) sum += i; // 防止x=1情况，i=1 x=1
if (i != x / i && x / i < x) sum += x / i;
// 当5*5=25时，判断1已经加上了5，为了防止判断2再加5，所以需要限制
// 6开根号=2.4，所以i=2，所以需要判断2来补齐还有约数3的情况。
}
if (sum == x) cout << x << " is perfect" << endl;
else cout << x << " is not perfect" << endl;
}
return 0;
}


23小时前
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
int m, n;
while(cin >> m >> n, m > 0 && n > 0)
{
if (m > n) swap(m, n);
int sum = 0;
for (int i = m; i <= n; i ++)
{
cout << i << " ";
sum += i;
}
cout << "Sum=" << sum << endl;
}
return 0;
}


23小时前
#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
int a = 0, b = 1;
if (n == 1) cout << a << endl;
else if (n == 2) cout << a << " "<< b << endl;
else
{
cout << a << " "<< b;
for (int i = 3; i <= n; i ++)
{
int c = a + b;
a = b;
b = c;
cout << " "<< c;
}
}

return 0;
}


23小时前
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
int n;
cin >> n;

while (n -- )
{
int x, y;
cin >> x >> y;

if (x > y) swap(x, y);

int sum = 0;
for (int i = x + 1; i < y; i ++)
if (i % 2) sum += i;
cout << sum << endl;
}
return 0;
}


#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
int x = 0, y = 0;
for (int i = 0; i < n; i++)
{
int a;
cin >> a;
if (a >= 10 && a <= 20) x++;
else y++;
}
cout << x << " in" << endl;
cout << y << " out" << endl;

return 0;
}



#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
int a, count = 1;
char t;
double sum = 0, total_coney = 0, total_rat = 0, total_frog = 0;
while (cin >> a, cin >> t, count <= n)
{
if (t == 'C') total_coney += a;
else if (t == 'R') total_rat += a;
else total_frog += a;
sum += a;
count ++;
}

printf("Total: %.0lf animals\n", sum);
printf("Total coneys: %.0lf\n", total_coney);
printf("Total rats: %.0lf\n", total_rat);
printf("Total frogs: %.0lf\n", total_frog);
printf("Percentage of coneys: %.2lf %\n", total_coney / sum * 100);
printf("Percentage of rats: %.2lf %\n", total_rat / sum * 100);
printf("Percentage of frogs: %.2lf %\n", total_frog / sum * 100);

return 0;
}


#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;

for (int i = 1; i <= 10; i++)
cout << i << " x " << n << " = " << i * n << endl;

return 0;
}


#include <iostream>

using namespace std;

int main()
{
int x;
cin >> x;

if (x % 2 == 1)
{
cout << x << endl;
for (int i = 1; i < 6; i ++)
{
x += 2;
cout << x << endl;
}
}

else
{
cout << x + 1<< endl;
x += 1;
for (int i = 1; i < 6; i ++)
{
x += 2;
cout << x << endl;
}
}
return 0;
}