#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 5 #define R1 586 #define R2 701 int main() { int number; int i; srand(time(0)); for(i=0;i<N;++i) { number=rand()%(R2-R1+1)+R1; printf("20228330%04d\n",number); } return 0; }
task1
#include<stdio.h> #include<math.h> int main() { double x,ans; scanf("%lf",&x); ans = pow(x,365); printf("%.2fµÄ365´Î·½£º%.2f\n",x,ans); return 0; }
#include<stdio.h> #include<math.h> int main() { double x,ans; while(scanf("%lf",&x)!=EOF) { ans=pow(x,365); printf("%.2fµÄ365´Î·½:%.2f\n",x,ans); printf("\n"); } return 0; }
task2
#include <stdio.h> #include<stdlib.h> int main() { double x, y; char c1, c2, c3; int a1, a2, a3; scanf("%d%d%d", &a1, &a2, &a3); /*加&*/ printf("a1 = %d, a2 = %d, a3 = %d\n", a1, a2, a3); getchar(); scanf("%c%c%c", &c1, &c2, &c3); getchar(); printf("c1 = %c, c2 = %c, c3 = %c\n", c1, c2, c3); scanf("%lf,%lf", &x, &y); /*lf*/ printf("x = %lf, y = %lf\n", x, y); system("pause"); return 0; }
task3
#include<stdio.h> #include<math.h> int main() { double c,F; while(scanf("%lf",&c)!=EOF) { F=c*9/5+32; printf("ÉãÊ϶Èc=%.2fʱ£¬»ªÊ϶Èf=%.2f\n",c,F); printf("\n"); } return 0; }
task3.2
#include<stdio.h> #include<stdlib.h> int main() { char c; while(scanf("%c", &c) != EOF) { getchar(); if(c == 'r') printf("stop!\n"); else if(c == 'g') printf("go go go\n"); else if(c == 'y') printf("wait a minute\n"); else printf("something must be wrong...\n"); } system("pause"); return 0; }
task4
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> int main() { int i,x,d; srand(time(0)); d=rand()%30+1; printf("猜猜2023年4月哪一天会是你的lucky day\n"); printf("开始喽,你有三次机会,猜吧(1~30):"); scanf("%d",&x); for(i=1;i<=3;i++) { if(x==d) { printf("噫,中了"); break; } else if(x < d) { printf("你的日期猜早了,你的lucky day还没到呢\n"); scanf("%d", &x); printf("\n"); continue; } else { printf("你的日期猜晚了,你的lucky day已经过了\n"); printf("再猜(1~30):"); scanf("%d", &x); printf("\n"); continue; } } printf("你的次数用完了,偷偷告诉你:4月,你的lucky day是%d号", d); }
task5
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> int main() { int i, j; for(i = 1;i <= 9; i++) { for(j = 1;j <= i; j++) { printf("%d*%d =%3d ", j, i, j * i); } printf("\n"); } system("pause"); return 0; }
task6
#include<stdio.h> #include<stdlib.h> int main() { int n; printf("input n:"); scanf("%d", &n); for(int i = 1;i <= n; i++) { for(int k = 1;k <= 3; k++) { for(int j = 1;j <= i - 1; j++) { printf(" "); } for(int j = 1;j <= 2 * (n - i) + 1; j++) { if(k == 1) printf(" O "); if(k == 2) printf("<H> "); if(k == 3) printf("I I "); } printf("\n"); } } system("pause"); return 0; }
task7
标签:lf,include,shiyan,int,scanf,printf,main From: https://www.cnblogs.com/nbb233/p/17223569.html