三位数反转(1)
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
printf("%d%d%d\\n", n % 10, n / 10 % 10, n / 100);
return 0;
}
三位数反转(2)
#include <stdio.h>
int main()
{
int n, m;
scanf("%d", &n);
m = (n % 10) \* 100 + (n / 10 % 10) \* 10 + n / 100;
printf("%03d", m);
return 0;
}
鸡兔同笼
#include <stdio.h>
int main()
{
int a, b, n, m;
scanf("%d %d", &n, &m);
a = (4 \* n - m) / 2;
b = n - a;
if (m % 2 == 1 a < 0 b < 0)
printf("No answer");
else
printf("%d %d", a, b);
return 0;
}
三整数排序
#include <stdio.h>
int main()
{
int a, b, c, t;
scanf("%d %d %d", &a, &b, &c);
if (a > b)
{
t = a;
a = b;
b = t;
}
if (a > c)
{
t = a;
a = c;
c = t;
}
if (b > c)
{
t = b;
b = c;
c = t;
}
printf("%d %d %d", a, b, c);
return 0;
}
/*
3 1 2
1 3 2
1 2 3
2 3 1
1 3 2
1 2 3
*/
平均数
#include <stdio.h>
int main()
{
int a, b, c;
double ave;
scanf("%d %d %d", &a, &b, &c);
printf("%.3f", (double)(a + b + c) / 3);
return 0;
}
温度
#include <stdio.h>
int main()
{
double f, c;
scanf("%lf", &f);
c = 5 \* (f - 32) / 9;
printf("%.3f", c);
return 0;
}
连续和
#include <stdio.h>
int main()
{
int n, sum;
scanf("%d", &n);
sum = n \* 1 + ((n \* (n - 1)) / 2);
printf("%d", sum);
return 0;
}