task.1
#include <stdio.h> #include <stdlib.h> #include <time.h> #define N 5 #define N1 374 #define N2 465 int main() { int number; int i; srand( time(0) ); // 以当前系统时间作为随机种子 for(i = 0; i < N; ++i) { number = rand()%(N2 - N1 + 1) + N1; printf("202383290376%04d\n", number);
} return 0; }
#include<stdio.h> int main(){ char n; while(scanf("%c",&n)!=EOF){ getchar(); switch(n){ case'r': printf("stop!\n");break; case'g': printf("go go go\n");break; case'y': printf("wait for a mintue\n");break; default: printf("something must be wrong...\n");break; } }return 0; }
#include<stdio.h> #include<time.h> #include<stdlib.h> #define N 3 #define N1 1 #define N2 30 int main(){ int i,n,number; i=1,n=3; printf("猜猜2023年哪天会是你的lucky day"); printf("开始了,你有三次机会,猜吧(0~30)") ; number=rand()%(N2-N1)+1; while(i<N,++i){ scanf("%d",&n); if(n<number){ printf("你猜的日期早了,你的lucky day还没到呢"); printf("再猜(0~30)" );} else if(n>number) { } printf("你猜的日期晚了,你的lucky day已经过了"); printf("再猜(0~30)" );} else{ printf("哇 猜中了") ;break;} }return 0; }
#include<stdio.h> int main(){ int n,a,i,t=0; double sum=0; while(scanf("%d%d",&n,&a)!=EOF){ for(i=1;i<=n;i++){ t=t*10+a; sum=1.0*i/t+sum; } printf("n=%d,a=%d,s=%lf",n,a,sum); } }
#include<stdio.h> int main(){ int a,b; for(a=1;a<=9;a++){ for(b=1;b<=a;b++) printf("%d*%d=%d\t",a,b,a*b); printf("\n"); } return 0; }
#include<stdio.h> int main(){ int n,a,b,s,m; printf("请输入n:"); scanf("%d",&n); m=n; for(;n>0;n--){ for(s=n;s<m;s++) printf("\t"); for(a=2*n-1;a>0;a--){ printf(" O \t"); } printf("\n"); for(s=n;s<m;s++) printf("\t"); for(a=2*n-1;a>0;a--){ printf("<H>\t"); } printf("\n"); for(s=n;s<m;s++) printf("\t"); for(a=2*n-1;a>0;a--){ printf("I I\t"); } printf("\n"); } return 0; }
问题1计算学号后四位
问题2随机抽取学生回答问题
标签:include,task.2,int,number,printf,main,define From: https://www.cnblogs.com/wxz2005/p/17767931.html