实践一
试验任务一
#include<stdio.h> #include<stdlib.h> int main() { printf("o \n"); printf("<H>\n"); printf("I I\n"); system("pause"); return 0; }
试验任务2
#include<stdio.h> #include<stdlib.h> int main() { int n,sum; scanf("%d", &n); sum=n*(n+1)/2; printf("sum = %d\n", sum);
system("pause"); return 0; }
#include<stdio.h> #include<stdlib.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, a); system("pause"); return 0; }
#include<stdio.h> #include<stdlib.h> int main() { intx, 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); system("pause"); return 0; }
![](https://img2023.cnblogs.com/blog/3122624/202303/3122624-20230304230323520-1995815757.png)
#include<stdio.h> #include<stdlib.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); system("pause"); return 0; }
#include<stdio.h> #include<stdlib.h> int main() { float a, b, c; scanf("%f%f%f", &a, &b, &c); if (a+b>c && abs(a-b)<c) printf("能构成三角形\n"); else printf("不能构成三角形\n"); system("pause"); return 0; }
#include<stdio.h> #include<stdlib.h> int main() { int year; year = 10^9 / 60 / 60 / 24 / 365; printf("十亿秒约等于%d\n", year); system("pause"); return 0; }
#include<stdio.h> #include<stdlib.h> int main() { int n; n = rand() % 41 + 60; printf("n = %d\n", n); system("pause"); return 0; }
#include<stdio.h> #include<stdlib.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"); system("pause"); return 0; }