|
|
|
|
|
|
随笔分类 -
C语言
杨辉三角
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int i,j; int n[10][10]={1}; //初始化数组 //用外循环控制二维数组的行 for(j=0;j<10;j++) { //用内循环控制二维数组的列
阅读全文
分珠子 1999次后的结果
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int box[4]={8,5,3,2}; int max; //最大盒子编号数 int insert;//最多珠子盒子编号 int i,j; //用作循环的变量 //用j变量来确定拿珠子的次数 ...
阅读全文
选择数组排序
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int b,c,n,x; int a[100]; int i; printf("你想输入多少个数:"); scanf("%d",&n); for(i=0;ia[c]) { x=a[b]; a[b]=a[c]; a...
阅读全文
数组排序
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int a,b,c,d,sum=0; int n[]={10,20,40,24,45,53,32,54,23,7}; for(a=0;an[d]) { a=n[c]; n[c]=n[d]; ...
阅读全文
求算个十百输出
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int b,s,g; for(b=0;b<10;b++) { for(s=0;s<10;s++) { for(g=0;g<10;g++) { pri...
阅读全文
求算反弹高度
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { float sn=100.0,hn=sn/2; int n; n=2; do { sn=sn+2*hn; hn=hn/2; n++; }while(n<=10); printf("第十次落地时,共经过%f米\n\n",sn); printf("...
阅读全文
九九乘法表
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int i,j; for(i=1;i<=9;i++) { for(j=1;j<=i;j++) { printf("%d*%d=%d\t",i,j,i*j); } printf("\n"); } }
阅读全文
等腰三角形字母
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int row,col;//行 列 for(row=1;row<7;row++) //定义行 { for(col=1;col<7-row;col++) { printf(" ");...
阅读全文
求100内数的偶数和
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int a=1,sum=0; for(;a<=100;a+=2) { sum+=a; } printf("%d",sum); }
阅读全文
数的平方和
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int a=1,sum=0; for(;a<=100;a+=2) { sum+=a; printf("%d\n",sum); } for(a=1;a<=100;a++) ...
阅读全文
班长的选举
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" #include "string.h" void main() { int zs,ls,ww,zl;//定义一个给参选人员的票数 int max;// int xuhao;// char name[5];//参选人员的名字 zs=ls=ww=zl=0;//初始票数都为0 pr...
阅读全文
求算 1到10的阶乘和
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int i,j;/* i是1-10之间的任一整数,j是i-1之间的任一整数*/ long int result;//result是1-10之间每个数的阶乘结果result=1; long int sum=0;//sum是每个数的阶乘结果之和 for(i=1;i...
阅读全文
计算素数个数 并输出
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int m,i,k,h=0,leap; m=101; while(m<=200)//用while确定101-200之间的整数范围 { k=m/2;//求出101-200之间的任一整数的2/1 i=2; ...
阅读全文
计算某年某月是某年的第几天
摘要:/* Note:My name is zxf */ #include "stdio.h" void main() { int year,month,day,sumdays,maxdays,xx,yy,zz,yueshu; int x; printf("请输入一个年份:"); xx: x=scanf("%d",&year); if(x!=1||year9999) {...
阅读全文
计算利润
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { //定义变量 long int i; double bonus1,bonus2,bonus4,bonus6,bonus10,bonus; //输入利润数 printf("请输入利润数"); scanf("%1d",&i); ...
阅读全文
空矩形星星排列图源程序
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" void main() { int row,col,r,c; printf("请输入行数"); scanf("%d",&row); printf("请输入列数"); scanf("%d",&col); for(r=1;r1&&r1&&c<col) printf("...
阅读全文
点名源程序
摘要:/* Note:Your choice is C IDE */ #include "stdio.h" #include "stdlib.h" #include "time.h" void main() { int i,j; char name; srand((unsigned)time(NULL)); for(j=1;j<=10;j++) { ...
阅读全文
|
|