标签:code mat sqrt input isp pen img turn tchar
8
1 #include 2 int num[100];
3 int main()
4 {
5 int x;
6 int cnt = 0;
7 scanf("%d", &x);
8 while(x) {
9 num[++cnt] = x % 10;
10 x = x / 10;
11 }
12 if(!cnt) printf("0\n");
13 else {
14 for(int i = cnt; i>=1; i--)
15 printf("%d\n", num[i]);
16 }
17 return 0;
18 }
View Code
9
1 #include2 int main()
3 {
4 int x;
5 scanf("%d", &x);
6 printf("%c\n", x);
7 return 0;
8 }
View Code
10
#includeint main()
{
int x;
scanf("%d",&x);
printf("x=%d,x=%o,x=%x\n", x, x, x);
return 0;
}
// -1
// x=-1,x=37777777777, x=ffffffff
View Code
11
#includeint main()
{
int x, y, ans;
char op;
scanf("%d %c %d", &x, &op, &y);
if(op==‘+‘)
ans = x + y;
else if(op==‘-‘)
ans = x - y;
else if(op==‘/‘)
ans = x / y;
else
ans = x % y;
printf("%d\n", ans);
return 0;
}
View Code
12
#includeint fun(int x, char op, int y) {
int ans;
if(op==‘+‘)
ans = x + y;
else if(op==‘-‘)
ans = x - y;
else if(op==‘/‘)
ans = x / y;
else
ans = x % y;
return ans;
}
int main()
{
int x, y;
char op;
scanf("%d %d %c",&x, &y, &op);
if(op==‘/‘ && y==0)
printf("Go to hell!\n");
printf("%d\n", fun(x, op, y));
return 0;
}
View Code
13
#includeint main()
{
int op;
double d, ans;
scanf("%d %lf", &op, &d);
if(op==1) {
ans = (d - 32) * 5 / 9;
printf("The Centigrade is %.2lf\n", ans);
}
else {
ans = (d * 9 / 5) + 32;
printf("The Fahrenheit is %.2lf\n", ans);
}
return 0;
}
View Code
16
#includeint main()
{
char op;
op = getchar();
if(op>=‘a‘ && op‘z‘)
op = op - ‘a‘ + ‘A‘;
else if(op>=‘A‘ && op‘Z‘)
op = op - ‘A‘ + ‘a‘;
printf("%c\n", op);
return 0;
}
View Code
19
#include
#includeint main()
{
int a, b, c;
double x1, x2;
scanf("%d %d %d", &a, &b, &c);
if(a==0&&b==0)
printf("Input error!\n");
else if(a==0){
x1 = - double(b) / c;
printf("x=%.6f\n", x1);
}
else {
double t = b * b - 4 * a * c;
if(t==0)
printf("x1=x2=%.6f\n",-double(b)/(2*a));
else if(t>0){
x1 = (-b + sqrt(t)) / (2 * a);
x2 = (-b - sqrt(t)) / (2 * a);
printf("x1=%.6f\nx2=%.6f\n",x1, x2);
}
else {
x1 = -double(b) / (2 * a);
x2 = sqrt(-t) / (2 * a);
printf("x1=%.6f%+.6fi\n", x1, x2);
printf("x2=%.6f%+.6fi\n", x1, -x2);
}
}
return 0;
}
View Code
20
#include
#includeint main()
{
int x, y;
while(scanf("%d %d", &x, &y)!=EOF) {
// 分针走的时候 时针也走
double x_pos = (x%12) * 5 + double(y) / 60.0 * 5;
// 把整个表分成60份: (x%12) * 5 -- 时针本来的位置; double(y) / 60.0 * 5 -- 因为分针,时针走的位置
double ans = fabs(x_pos - y) 30.0 ? fabs(x_pos - y) : 60.0 - fabs(x_pos - y);
// 求最小夹角
printf("At %02d:%02d the angle is %.1lf degrees.\n", x, y, ans * 6.0);
// ans * 6.0 一份是6度
}
return 0;
}
View Code
2020计算机C语言
标签:code mat sqrt input isp pen img turn tchar
原文地址:https://www.cnblogs.com/xidian-mao/p/14008263.html