資源描述:
《循環(huán)結(jié)構(gòu)例題》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、#include"stdio.h"main(){inti=1;while(i<1000){printf(“%d”,i);i++;}}#include"stdio.h"main(){inti=1,s=0;while(i<100){s=s+i;i++;}printf(“%d”,s);}#include"stdio.h"main(){inti=1,s=0,p=1,n;scanf(“%d”,&n);while(i<=n){p=p*i;s=s+p;i++;}printf(“%d”,s);}#include"stdio.h"#include"math.h"main(){floatx1=10
2、,x2=-10,x,y1,y2,y;x=(x1+x2)/2;y=2*x*x*x-4*x*x+3*x-6;while(fabs(y)>1e-5){y1=2*x1*x1*x1-4*x1*x1+3*x1-6;if(y*y1>0)x1=x;elsex2=x;x=(x1+x2)/2;y=2*x*x*x-4*x*x+3*x-6;}printf("therootis%f",x);}#include"stdio.h"main(){inti,f1,f2,f3;f1=1;f2=1;printf("%d,%d",f1,f2);for(i=3;i<=20;i++){f3=f1+f2;f1=f2;f2=f3;p
3、rintf(",%d",f3);}}#include"stdio.h"main(){intx,n=0,s=0;while(n<10){scanf("%d",&x);if(x<0)break;s+=x;n++;}printf("s=%d",s);}#include"stdio.h"main(){intx,n=0,s=0;while(n<10){scanf("%d",&x);if(x<0)continue;s+=x;n++;}printf("s=%d",s);}#include"stdio.h"main(){intx,n=0,s=0;while(n<10){scanf("%d",&x)
4、;n++;if(x<0)continue;s+=x;}printf("s=%d",s);}#include"stdio.h"main(){inti=2,m;scanf("%d",&m);while(m%i!=0)i++;if(i==m)printf("%dshisushu!",m);elseprintf("%dbushisushu!",m);}#include"stdio.h"main(){inti,m;scanf("%d",&m);for(i=2;m%i!=0;i++);if(i==m)printf("%dshisushu!",m);elseprintf("%dbushi
5、sushu!",m);}#include"stdio.h"main(){inti,m;scanf("%d",&m);for(i=2;i<=m;i++)if(m%i==0)break;if(i==m)printf("%dshisushu!",m);elseprintf("%dbushisushu!",m);}#include"stdio.h"#include"math.h"main(){inti,m,s;scanf("%d",&m);s=sqrt(m);for(i=2;i<=s;i++)if(m%i==0)break;if(i==s+1)printf("%dshisushu!
6、",m);elseprintf("%dbushisushu!",m);}#include"stdio.h"#include"math.h"main(){inti,j;for(i=100;i<=200;i++){for(j=2;j<=i;j++)if(i%j==0)break;if(j==i)printf("%-10d",i);}}#include"stdio.h"#include"math.h"main(){inti,j,s;for(i=100;i<=200;i++){s=sqrt(i);for(j=2;j<=s;j++)if(i%j==0)break;if(j==s+1)printf
7、("%-10d",i);}}#includemain(){inti,j,s;for(i=2;i<=10000;i++){s=0;for(j=1;j