task1
代码
#include <stdio.h> int main() { printf(" O O \n"); printf("<H> <H>\n"); printf("I I I I\n"); return 0; }
图片
代码
#include <stdio.h> int main() { printf(" O \n"); printf("<H>\n"); printf("I I\n"); printf(" O \n"); printf("<H>\n"); printf("I I\n"); return 0; }
图片
task2.c
代码
#include <stdio.h> int main() { int n, sum; scanf("%d",&n); sum=n*(n+1)/2; printf("sum = %d\n", sum); return 0; }
图片
task3.c
代码
#include <stdio.h> int main() { int a, b, t; a = 3; b = 4; printf("a = %d, b = %d\n", a, b); t = a; a = b; b = t; printf("a = %d, b = %d\n", a, b); return 0; }
图片
结论:将a的值给b,b的值给a
task4.c
代码
#include <stdio.h> int main() { int x, t, m; x = 123; printf("x = %d\n", x); t = 0; m = x % 10; t = t *10 + m; x = x / 10; m = x % 10; t = t * 10 + m; x = x / 10; m = x % 10; t = t * 10 + m; x = x / 10; printf("t = %d\n", t); return 0; }
图片
结论:求出x各个位的数字
task5.c
代码
#include <stdio.h> int main() { float a, b, c; scanf("%f%f%f", &a, &b, &c); if((a+b>c)&&(a-b<c)) printf("能构成三角形\n"); else printf("不能构成三角形\n"); return 0; }
图片
task6.c
代码
#include <stdio.h> int main() { int year, s; long double k; s = 1e+9; k = s/60/60/24/365; year = (int)(k+0.5); printf("十亿秒约等于%d年\n", year); return 0; }
图片
task7.c
代码
标签:10,include,return,int,实验,printf,main From: https://www.cnblogs.com/zzaw/p/17182062.html