#include<stdio.h> #include<math.h> int main() { int n,a,up,down,i=1; double s; while(scanf("%d%d",&n,&a)==2) {while(i<=n) {up=i; down+=a*pow(10,i-1); s+=up*1.0/down; i++; } printf("n=%d,a=%d,s=%lf\
#include<stdio.h> int main() { int n,i,j,k; printf("input n:"); scanf("%d",&n); for(i=1;i<=n;i++) {for(k=1;k<i;k++) printf("\t"); while(j<=2*n+1-2*i) {printf(" O\t"); j++; } j=1; printf("\n"); for(k=1;k<i;k++) printf("\t"); while(j<=2*n+1-2*i) {printf(" -H>\t"); j++; } j=1; printf("\n"); for(k=1;k<i;k++) printf("\t"); while(j<=2*n+1-2*i) {printf(" J l\t"); j++; } j=1; printf("\n"); } return 0; }
n",n,a,s); i=1; down=0; s=0; } return 0; }
#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 color; while(1) {scanf(" %c",&color); if(color=='y') printf("wait a minute\n"); else if(color=='r') printf("stop!\n"); else if(color=='g') printf("go go go\n"); else printf("something must be wrong...\n"); } return 0; }
#include<stdio.h> #include<time.h> #include<stdlib.h> int main() { int d,ans,i=1; d=3; printf("猜一猜2023年11月哪一天会是你的lucky day~\n开始喽,你有三次机会,猜吧(1~30):"); while(i<=3) {scanf("%d",&ans); if(ans==d) {printf("哇,猜中了!"); break;} else if(ans<d) printf("你猜的日期早了,你的lucky day还没到呢\n再猜:") ; else if(ans>d) printf("你猜的日期晚了,你的lucky day已经过啦\n再猜:") ; i++; } if(i==4) printf("次数用完啦,偷偷告
诉你:11月的lucky day是%d号",d); return 0;
}
#include<stdio.h> #include<math.h> int main() { int n,a,up,down,i=1; double s; while(scanf("%d%d",&n,&a)==2) {while(i<=n) {up=i; down+=a*pow(10,i-1); s+=up*1.0/down; i++; } printf("n=%d,a=%d,s=%lf\n",n,a,s); i=1; down=0; s=0; } return 0; }
标签:include,int,color,while,实验,printf,main From: https://www.cnblogs.com/nmsl22/p/17769055.html