#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 5 int main() { int i,number; srand(time(0)); for(i=0;i<=N;++i) { number=rand()%500+1;//生成1-500之间的随机数 printf("20228329%04d\n",number); } return 0; } //随机生成学号
#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int i,j,number; printf("猜猜2022年11月哪一天会是你的lucky day\n"); printf("开始喽,你有三次机会,猜吧(1~30):"); srand(time(0)); number=rand()%30+1; for(i=1;i<=3;++i) { scanf("%d",&j); printf("\n"); if(j<1||j>30) exit(0); if(j>number) printf("你猜的日期晚了,你的lucky day已经过啦\n"); if(j<number) printf("你猜的日期早了,你的lucky day还没到呢\n"); printf("再猜:"); if(j==number) { printf("哇,猜中了:—)"); exit(0); } } printf("次数用完啦,偷偷告诉你:11月,你的lucky day是:%d号",number); return 0; }
#include<stdio.h> int main() { char x,r,g,y; while(scanf("%c",&x)!=EOF) { getchar(); if(x!='r'&&x!='g'&&x!='y') printf("something must be wrong...\n"); if(x=='r') printf("stop!\n"); if(x=='g') printf("go go go\n"); if(x=='y') printf("wait a minute\n"); } return 0; }
#include<stdio.h> int main() { double p,sum,b; int n,a,i; while(scanf("%d %d",&n,&a)!=EOF) { b=1; p=a; for(i=1,sum=0;i<=n;i++) { sum+=b/p; b=b+1; p=p*10+a; } printf("n=%d,a=%d,sum=%lf\n",n,a,sum); } return 0; }
#include<stdio.h> int main() { int i,j,s; for(i=1;i<=9;++i) { for(j=1;j<=i;++j) { s=j*i; printf("%d*%d= %2d ",j,i,s); } printf("\n"); } return 0; }
#include<stdio.h> int main() { int i, j, n, a, b,c,v,d,h; scanf_s("%d", &n); a = n; for (i = 1; i <= n; i++) { for (j = 1; j < i; j++) printf("\t"); for (b = 1; b <= (2 * a - 1); b++) printf(" o \t"); printf("\n"); for (c = 1; c < i; c++) printf("\t"); for (v = 1; v <= (2 * a - 1); v++) printf("<H>\t"); printf("\n"); for (d = 1; d < i; d++) printf("\t"); for (h = 1; h <= (2 * a - 1); h++) printf("I I\t"); printf("\n"); a = a - 1; } return 0; }
第i行,需要打印2n-2i+1个字符小人
第i行,前面需要打印[i/4]*11空白(需要使用[i/4]个 \t )
标签:include,int,number,实验,printf,go,main From: https://www.cnblogs.com/lc12/p/16814676.html