欢迎来到天天文库
浏览记录
ID:37911126
大小:36.50 KB
页数:4页
时间:2019-06-02
《C语言实验六解答》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、2.1#includevoidmain(){inti1,i2,i,j,flag;printf("inputtwointeger(i1,i2):");scanf("%d%d",&i1,&i2);printf("primenumber:");for(i=i1;i<=i2;i++){flag=1;for(j=2;j<=i-1;j++){if(i%j==0){flag=0;break;}}if(flag==1)printf("%dt",i);}printf("");getch();}2.2#include2、dio.h>voidmain(){inti,j;for(i=1;i<=9;i++){for(j=1;j<=9;j++)printf("%d*%d=%dt",i,j,j*i);printf("");}getch();}3.1#includevoidmain(){intx,s,a;for(x=100;x<1000;x++){a=x;while(a!=0){s=s+(a%10)*(a%10)*(a%10);a=a/10;}if(x=s)printf("%d",x);}getch();}3.2#include3、dio.h>voidmain(){inti,j;ints;for(i=1;i<=999;i++){s=0;for(j=1;j<=i-1;j++){if(i%j==0)s=s+j;}if(s=i)printf("%d",i);}getch();}4.1#includevoidmain(){intx,s,a;for(x=100;x<1000;x++){a=x;while(a!=0){s=s+(a%10)*(a%10)*(a%10);a=a/10;}if(s=1009)printf("%d",x);}getch();}4、4.2#includemain(){inti,j,m;m=1;for(i=3;i>=0;i--){for(j=i;j>0;j--)printf("");for(j=m;j>0;j--)printf("*");printf("");m=m+2;}m=5;for(i=1;i<=3;i++){for(j=i;j>0;j--)printf("");for(j=m;j>0;j--)printf("*");printf("");m=m-2;}getch();}4.3#include#include<5、math.h>voidmain(){floatx,x0,f,f0;x=1.5;do{x0=x;f=2*x0*x0*x0-4*x0*x0+3*x0-6;f0=6*x0*x0-8*x0+3;x=x0-f/f0;}while(fabs(x-x0)>=1e-5);printf("x=%f",x);getch();}4.4#include"stdio.h"voidmain(){unsignedlonginta[50];unsignedlonginti,j=0,m,x,y;printf("putinfiftynumbers,并在每两个数字6、之间以回车分开");for(i=0;i<50;i++)scanf("%d",&a[i]);printf("您输入的50个数字为:");for(i=0;i<50;i++){printf("%7d",a[i]);if((i+1)%10==0)printf("");}printf("各位数字平方和等于108的数字为:");for(i=0;i<50;i++){x=a[i];m=y=0;while(x!=0){y=x%10;x=x/10;m+=y*y;}if(m==108){printf("%d",a[i]);j7、++;}}if(j==0)printf("sorry,nofigurematch");getch();}
2、dio.h>voidmain(){inti,j;for(i=1;i<=9;i++){for(j=1;j<=9;j++)printf("%d*%d=%dt",i,j,j*i);printf("");}getch();}3.1#includevoidmain(){intx,s,a;for(x=100;x<1000;x++){a=x;while(a!=0){s=s+(a%10)*(a%10)*(a%10);a=a/10;}if(x=s)printf("%d",x);}getch();}3.2#include3、dio.h>voidmain(){inti,j;ints;for(i=1;i<=999;i++){s=0;for(j=1;j<=i-1;j++){if(i%j==0)s=s+j;}if(s=i)printf("%d",i);}getch();}4.1#includevoidmain(){intx,s,a;for(x=100;x<1000;x++){a=x;while(a!=0){s=s+(a%10)*(a%10)*(a%10);a=a/10;}if(s=1009)printf("%d",x);}getch();}4、4.2#includemain(){inti,j,m;m=1;for(i=3;i>=0;i--){for(j=i;j>0;j--)printf("");for(j=m;j>0;j--)printf("*");printf("");m=m+2;}m=5;for(i=1;i<=3;i++){for(j=i;j>0;j--)printf("");for(j=m;j>0;j--)printf("*");printf("");m=m-2;}getch();}4.3#include#include<5、math.h>voidmain(){floatx,x0,f,f0;x=1.5;do{x0=x;f=2*x0*x0*x0-4*x0*x0+3*x0-6;f0=6*x0*x0-8*x0+3;x=x0-f/f0;}while(fabs(x-x0)>=1e-5);printf("x=%f",x);getch();}4.4#include"stdio.h"voidmain(){unsignedlonginta[50];unsignedlonginti,j=0,m,x,y;printf("putinfiftynumbers,并在每两个数字6、之间以回车分开");for(i=0;i<50;i++)scanf("%d",&a[i]);printf("您输入的50个数字为:");for(i=0;i<50;i++){printf("%7d",a[i]);if((i+1)%10==0)printf("");}printf("各位数字平方和等于108的数字为:");for(i=0;i<50;i++){x=a[i];m=y=0;while(x!=0){y=x%10;x=x/10;m+=y*y;}if(m==108){printf("%d",a[i]);j7、++;}}if(j==0)printf("sorry,nofigurematch");getch();}
3、dio.h>voidmain(){inti,j;ints;for(i=1;i<=999;i++){s=0;for(j=1;j<=i-1;j++){if(i%j==0)s=s+j;}if(s=i)printf("%d",i);}getch();}4.1#includevoidmain(){intx,s,a;for(x=100;x<1000;x++){a=x;while(a!=0){s=s+(a%10)*(a%10)*(a%10);a=a/10;}if(s=1009)printf("%d",x);}getch();}
4、4.2#includemain(){inti,j,m;m=1;for(i=3;i>=0;i--){for(j=i;j>0;j--)printf("");for(j=m;j>0;j--)printf("*");printf("");m=m+2;}m=5;for(i=1;i<=3;i++){for(j=i;j>0;j--)printf("");for(j=m;j>0;j--)printf("*");printf("");m=m-2;}getch();}4.3#include#include<
5、math.h>voidmain(){floatx,x0,f,f0;x=1.5;do{x0=x;f=2*x0*x0*x0-4*x0*x0+3*x0-6;f0=6*x0*x0-8*x0+3;x=x0-f/f0;}while(fabs(x-x0)>=1e-5);printf("x=%f",x);getch();}4.4#include"stdio.h"voidmain(){unsignedlonginta[50];unsignedlonginti,j=0,m,x,y;printf("putinfiftynumbers,并在每两个数字
6、之间以回车分开");for(i=0;i<50;i++)scanf("%d",&a[i]);printf("您输入的50个数字为:");for(i=0;i<50;i++){printf("%7d",a[i]);if((i+1)%10==0)printf("");}printf("各位数字平方和等于108的数字为:");for(i=0;i<50;i++){x=a[i];m=y=0;while(x!=0){y=x%10;x=x/10;m+=y*y;}if(m==108){printf("%d",a[i]);j
7、++;}}if(j==0)printf("sorry,nofigurematch");getch();}
此文档下载收益归作者所有