欢迎来到天天文库
浏览记录
ID:37927933
大小:646.23 KB
页数:109页
时间:2019-06-03
《C语言基本算法程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、(╯_╰)母鸡荣誉作品以下一百例C语言基本程序算法出自C语言基本算法程序一百例.pdf的word形式,并经过本人亲自在vc6.0上编写运行完美!!!第一章最简单的问题与算法1.绘制余弦曲线源程序:#include#includevoidmain(){doubley;intx,m;for(y=1;y>-1;y-=0.1)//y为列方向{m=acos(y)*10;//y对应的弧度mfor(x=1;x2、62-m;x++)printf("");printf("*");}}运行结果:******************************************Pressanykeytocontinue2..绘制余弦曲线和直线源代码:#include#includevoidmain(){doubley;intx,m,n,yy;for(yy=0;yy<=20;yy++){y=0.1*yy;//y:屏幕行方向坐标m=acos(1-y)*10;//m:cos(x)曲线3、上y点对应的屏幕列坐标n=45*(y-1)+31;for(x=0;x<=62;x++)if(x==m&&x==n)printf("+");elseif(x==n)printf("+");elseif(x==m4、5、x==62-m)printf("*");elseprintf("");printf("");}}运行结果:******+**+**+***+**+**+**+**+**+**+**+**+**+**+**+*****3.绘制圆源代码:#include#include6、th.h>voidmain(){doubley;intx,m;for(y=10;y>=-10;y--)//圆的半径为10{m=2.5*sqrt(100-y*y);//行y对应的列坐标m。2.5是屏幕纵横比调节系数,//因为屏幕的行距大于列距,不进行调节的话就显示为椭圆for(x=1;x<30-m;x++)printf("");printf("*");for(;x<30+m;x++)printf("");printf("*");}}运行结果:*****************************7、*************Pressanykeytocontinue4.歌星大奖赛源代码:#include#includevoidmain(){intinteger,i,max,min,sum;max=-32768;min=32767;//-32768~+32767为C语言的整型数的最值sum=0;for(i=1;i<=10;i++){printf("inputnumber%d=",i);scanf("%d",&integer);sum+=integer;if(int8、eger>max)max=integer;if(integer9、tnumber7=99inputnumber8=95inputnumber9=92inputnumber10=97Canceledmaxscore:99Canceleminscore:90Averagescore:93Pressanykeytocontinue5.求最大约数源代码:#include#includevoidmain(){longi;intj;printf("pleseinputnumber:");scanf("%ld",&i);for(j=999;j>=10、100;j--)if(i%j==0){printf("Themaxfactorwith3digitsin%ldis:%d.",i,j);break;}}运行结果:pleseinputnumber:555555Themaxfactorwith3digitsin555555is:777.Pressanykeytocontinue6.高次方数的尾数源代码:#include#includevoidmain(){inti,x,
2、62-m;x++)printf("");printf("*");}}运行结果:******************************************Pressanykeytocontinue2..绘制余弦曲线和直线源代码:#include#includevoidmain(){doubley;intx,m,n,yy;for(yy=0;yy<=20;yy++){y=0.1*yy;//y:屏幕行方向坐标m=acos(1-y)*10;//m:cos(x)曲线
3、上y点对应的屏幕列坐标n=45*(y-1)+31;for(x=0;x<=62;x++)if(x==m&&x==n)printf("+");elseif(x==n)printf("+");elseif(x==m
4、
5、x==62-m)printf("*");elseprintf("");printf("");}}运行结果:******+**+**+***+**+**+**+**+**+**+**+**+**+**+**+*****3.绘制圆源代码:#include#include6、th.h>voidmain(){doubley;intx,m;for(y=10;y>=-10;y--)//圆的半径为10{m=2.5*sqrt(100-y*y);//行y对应的列坐标m。2.5是屏幕纵横比调节系数,//因为屏幕的行距大于列距,不进行调节的话就显示为椭圆for(x=1;x<30-m;x++)printf("");printf("*");for(;x<30+m;x++)printf("");printf("*");}}运行结果:*****************************7、*************Pressanykeytocontinue4.歌星大奖赛源代码:#include#includevoidmain(){intinteger,i,max,min,sum;max=-32768;min=32767;//-32768~+32767为C语言的整型数的最值sum=0;for(i=1;i<=10;i++){printf("inputnumber%d=",i);scanf("%d",&integer);sum+=integer;if(int8、eger>max)max=integer;if(integer9、tnumber7=99inputnumber8=95inputnumber9=92inputnumber10=97Canceledmaxscore:99Canceleminscore:90Averagescore:93Pressanykeytocontinue5.求最大约数源代码:#include#includevoidmain(){longi;intj;printf("pleseinputnumber:");scanf("%ld",&i);for(j=999;j>=10、100;j--)if(i%j==0){printf("Themaxfactorwith3digitsin%ldis:%d.",i,j);break;}}运行结果:pleseinputnumber:555555Themaxfactorwith3digitsin555555is:777.Pressanykeytocontinue6.高次方数的尾数源代码:#include#includevoidmain(){inti,x,
6、th.h>voidmain(){doubley;intx,m;for(y=10;y>=-10;y--)//圆的半径为10{m=2.5*sqrt(100-y*y);//行y对应的列坐标m。2.5是屏幕纵横比调节系数,//因为屏幕的行距大于列距,不进行调节的话就显示为椭圆for(x=1;x<30-m;x++)printf("");printf("*");for(;x<30+m;x++)printf("");printf("*");}}运行结果:*****************************
7、*************Pressanykeytocontinue4.歌星大奖赛源代码:#include#includevoidmain(){intinteger,i,max,min,sum;max=-32768;min=32767;//-32768~+32767为C语言的整型数的最值sum=0;for(i=1;i<=10;i++){printf("inputnumber%d=",i);scanf("%d",&integer);sum+=integer;if(int
8、eger>max)max=integer;if(integer9、tnumber7=99inputnumber8=95inputnumber9=92inputnumber10=97Canceledmaxscore:99Canceleminscore:90Averagescore:93Pressanykeytocontinue5.求最大约数源代码:#include#includevoidmain(){longi;intj;printf("pleseinputnumber:");scanf("%ld",&i);for(j=999;j>=10、100;j--)if(i%j==0){printf("Themaxfactorwith3digitsin%ldis:%d.",i,j);break;}}运行结果:pleseinputnumber:555555Themaxfactorwith3digitsin555555is:777.Pressanykeytocontinue6.高次方数的尾数源代码:#include#includevoidmain(){inti,x,
9、tnumber7=99inputnumber8=95inputnumber9=92inputnumber10=97Canceledmaxscore:99Canceleminscore:90Averagescore:93Pressanykeytocontinue5.求最大约数源代码:#include#includevoidmain(){longi;intj;printf("pleseinputnumber:");scanf("%ld",&i);for(j=999;j>=
10、100;j--)if(i%j==0){printf("Themaxfactorwith3digitsin%ldis:%d.",i,j);break;}}运行结果:pleseinputnumber:555555Themaxfactorwith3digitsin555555is:777.Pressanykeytocontinue6.高次方数的尾数源代码:#include#includevoidmain(){inti,x,
此文档下载收益归作者所有