任务1:
1 #include <stdio.h> 2 int main() 3 { 4 printf(" O \n"); 5 printf("<H>\n"); 6 printf("I I\n"); 7 printf(" O \n"); 8 printf("<H>\n"); 9 printf("I I\n"); 10 11 return 0; 12 }
#include <stdio.h> int main() { printf(" O o\n"); printf("<H> <H>\n"); printf("I I I I\n"); return 0; }
任务2:
1 #include <stdio.h> 2 int main() 3 { 4 double a, b, c; 5 scanf("%lf%lf%lf", &a, &b, &c); 6 if(a+b>c && b+c>a && a+c>b) 7 printf("能构成三角形\n"); 8 else 9 printf("不能构成三角形\n"); 10 return 0; 11 }
任务3:
#include <stdio.h> int main() { char ans1, ans2; printf("每次课前认真预习、课后及时复习了没? (输入y或Y表示有,输入n或N表示没有) :"); ans1 = getchar(); getchar(); printf("\n动手敲代码实践了没? (输入y或Y表示敲了,输入n或N表示木有敲) : "); ans2 = getchar(); if ((ans1=='y'||ans1=='Y')&&(ans2=='y'||ans2=='Y')) printf("\n罗马不是一天建成的, 继续保持哦:)\n"); else printf("\n罗马不是一天毁灭的, 我们来建设吧\n"); return 0; }
回答问题:删去这一行会读取回车
任务4:
1 #include<stdio.h> 2 3 int main() 4 { 5 double x, y; 6 char c1, c2, c3; 7 int a1, a2, a3; 8 9 scanf(" %d %d %d",&a1,&a2,&a3); 10 printf("a1 = %d, a2 = %d, a3 = %d\n",a1,a2,a3); 11 12 scanf(" %c %c %c", &c1, &c2, &c3); 13 printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3); 14 15 scanf("%lf %lf", &x, &y); 16 printf("x = %lf, y = %lf\n",x,y); 17 return 0; 18 }
任务5:
1 #include <stdio.h> 2 int main() 3 { 4 int year; 5 double t; 6 t = 1000000000/(3600*24*365.0); 7 year = (t+0.5)/1; 8 printf("10亿秒约等于%d年\n", year); 9 return 0; 10 }
任务6:
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double x, ans; 6 7 while(scanf("%lf", &x) != EOF) 8 { 9 ans = pow(x, 365); 10 printf("%.2f的365次方: %.2f\n", x, ans); 11 printf("\n"); 12 } 13 return 0; 14 }
任务7:
1 #include<stdio.h> 2 int main() 3 { 4 double C, F; 5 while(scanf("%lf",&C)!=EOF){ 6 F=9*C/5.0+32; 7 printf("摄氏度c=%.2f时,华氏度f=%.2f",C,F); 8 } 9 return 0; 10 }
任务8:
1 #include <stdio.h> 2 #include <math.h> 3 int main() 4 { 5 double a,b,c,s,area; 6 while(scanf("%lf%lf%lf",&a,&b,&c)!=EOF) 7 { 8 s=(a+b+c)/2; 9 area=sqrt(s*(s-a)*(s-b)*(s-c)); 10 11 printf("a=%d,b=%d,c=%d,area= %.3f\n",(int)a,(int)b,(int)c,area); 12 13 } 14 return 0; 15 }
标签:lf,include,return,int,实验,printf,main From: https://www.cnblogs.com/zhy123ZHY/p/18443102