欢迎来到天天文库
浏览记录
ID:39472817
大小:77.50 KB
页数:11页
时间:2019-07-04
《华北电力大学c++实验指导循环结构程序设计参考答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、循环结构程序设计部分习题参考答案二1.改错题(1)正确程序如下:#includevoidmain(){inti,n,flag=-1;floatsum;sum=0;cin>>n;for(i=1;i<=n;i++){flag=-flag;sum=sum+1.0/i*flag;}cout<2、下:#include"iostream.h"voidmain(){intm,s,j;for(m=1;m<=1000;m++){s=0;for(j=1;jvoidmain(){intn,max=0,t;scanf("%d",&n);do{t=n%10;if(max3、.h>voidmain(){inti,k,sum=0,m,n,t,gs=0;cin>>m>>n;if(m>n){t=m;m=n;n=t;}for(k=m;k<=n;k++){for(i=2;i4、"voidmain(){intn,i;floats;s=1;cin>>n;for(i=1;i<=n;i++)s*=i;cout<>n;for(i=1;i<=n;i++)if(i%3==05、6、i%7==7)sum+=1.0/i;cout<<"sum="<7、oubles;n=2;cin>>q;s=2.0;while(s<=q){s=s+(double)(n+1)/n;n++;}cout<<"s="<>x;for(i=1;i<=x;i++)if(x%i==0)if(i%2!=0){cout<8、stream.h"voidmain(){inti,j,n,count=0;cin>>n;for(i=2;i<=n;i++){for(j=2;j=i){count++;cout<>n;for(i=2;i<=n;i=i+2){sum=sum+i;}cout<9、include"iostream.h"voidmain(){intn,g,b,s,count=0;for(n=100;n<1000;n++){g=n%10;s=n/10%10;b=n/100;if(g+b==s){count++;cout<>n;for(i=1;i<10、=n;i++){a=0;for(j=1;j<=i;j++)a+=j;s=s+1.0/a;}cout<
2、下:#include"iostream.h"voidmain(){intm,s,j;for(m=1;m<=1000;m++){s=0;for(j=1;jvoidmain(){intn,max=0,t;scanf("%d",&n);do{t=n%10;if(max3、.h>voidmain(){inti,k,sum=0,m,n,t,gs=0;cin>>m>>n;if(m>n){t=m;m=n;n=t;}for(k=m;k<=n;k++){for(i=2;i4、"voidmain(){intn,i;floats;s=1;cin>>n;for(i=1;i<=n;i++)s*=i;cout<>n;for(i=1;i<=n;i++)if(i%3==05、6、i%7==7)sum+=1.0/i;cout<<"sum="<7、oubles;n=2;cin>>q;s=2.0;while(s<=q){s=s+(double)(n+1)/n;n++;}cout<<"s="<>x;for(i=1;i<=x;i++)if(x%i==0)if(i%2!=0){cout<8、stream.h"voidmain(){inti,j,n,count=0;cin>>n;for(i=2;i<=n;i++){for(j=2;j=i){count++;cout<>n;for(i=2;i<=n;i=i+2){sum=sum+i;}cout<9、include"iostream.h"voidmain(){intn,g,b,s,count=0;for(n=100;n<1000;n++){g=n%10;s=n/10%10;b=n/100;if(g+b==s){count++;cout<>n;for(i=1;i<10、=n;i++){a=0;for(j=1;j<=i;j++)a+=j;s=s+1.0/a;}cout<
3、.h>voidmain(){inti,k,sum=0,m,n,t,gs=0;cin>>m>>n;if(m>n){t=m;m=n;n=t;}for(k=m;k<=n;k++){for(i=2;i4、"voidmain(){intn,i;floats;s=1;cin>>n;for(i=1;i<=n;i++)s*=i;cout<>n;for(i=1;i<=n;i++)if(i%3==05、6、i%7==7)sum+=1.0/i;cout<<"sum="<7、oubles;n=2;cin>>q;s=2.0;while(s<=q){s=s+(double)(n+1)/n;n++;}cout<<"s="<>x;for(i=1;i<=x;i++)if(x%i==0)if(i%2!=0){cout<8、stream.h"voidmain(){inti,j,n,count=0;cin>>n;for(i=2;i<=n;i++){for(j=2;j=i){count++;cout<>n;for(i=2;i<=n;i=i+2){sum=sum+i;}cout<9、include"iostream.h"voidmain(){intn,g,b,s,count=0;for(n=100;n<1000;n++){g=n%10;s=n/10%10;b=n/100;if(g+b==s){count++;cout<>n;for(i=1;i<10、=n;i++){a=0;for(j=1;j<=i;j++)a+=j;s=s+1.0/a;}cout<
4、"voidmain(){intn,i;floats;s=1;cin>>n;for(i=1;i<=n;i++)s*=i;cout<>n;for(i=1;i<=n;i++)if(i%3==0
5、
6、i%7==7)sum+=1.0/i;cout<<"sum="<7、oubles;n=2;cin>>q;s=2.0;while(s<=q){s=s+(double)(n+1)/n;n++;}cout<<"s="<>x;for(i=1;i<=x;i++)if(x%i==0)if(i%2!=0){cout<8、stream.h"voidmain(){inti,j,n,count=0;cin>>n;for(i=2;i<=n;i++){for(j=2;j=i){count++;cout<>n;for(i=2;i<=n;i=i+2){sum=sum+i;}cout<9、include"iostream.h"voidmain(){intn,g,b,s,count=0;for(n=100;n<1000;n++){g=n%10;s=n/10%10;b=n/100;if(g+b==s){count++;cout<>n;for(i=1;i<10、=n;i++){a=0;for(j=1;j<=i;j++)a+=j;s=s+1.0/a;}cout<
7、oubles;n=2;cin>>q;s=2.0;while(s<=q){s=s+(double)(n+1)/n;n++;}cout<<"s="<>x;for(i=1;i<=x;i++)if(x%i==0)if(i%2!=0){cout<
8、stream.h"voidmain(){inti,j,n,count=0;cin>>n;for(i=2;i<=n;i++){for(j=2;j=i){count++;cout<>n;for(i=2;i<=n;i=i+2){sum=sum+i;}cout<9、include"iostream.h"voidmain(){intn,g,b,s,count=0;for(n=100;n<1000;n++){g=n%10;s=n/10%10;b=n/100;if(g+b==s){count++;cout<>n;for(i=1;i<10、=n;i++){a=0;for(j=1;j<=i;j++)a+=j;s=s+1.0/a;}cout<
9、include"iostream.h"voidmain(){intn,g,b,s,count=0;for(n=100;n<1000;n++){g=n%10;s=n/10%10;b=n/100;if(g+b==s){count++;cout<>n;for(i=1;i<
10、=n;i++){a=0;for(j=1;j<=i;j++)a+=j;s=s+1.0/a;}cout<
此文档下载收益归作者所有