经典C程序.
whidy
zzzzzzzzzzzzzzzzzz
展开
-
兔子繁殖问题.
兔子繁殖问题. #includevoid main(void){ int month; int f[13]={1,1}; for(month=2;month { f[month]=f[month-1]+f[month-2]; } for(month=0;month { printf("%d ",f[month]); }}原创 2009-03-09 16:06:00 · 787 阅读 · 0 评论 -
二维数组置换
#includevoid main(){ int i,j,t; int a[3][3]={1,2,3,4,5,6,7,8,9}; for(i=0;i { for(j=0;j printf("%3d",a[i][j]); printf("/n"); } printf("/n"); for(i=0;i for(j=0;j { t=a[i][j]; a[i][j]=a[j][i];原创 2009-03-09 17:46:00 · 711 阅读 · 0 评论 -
输出数组a中的全部元素.
#includevoid main(){ int a[10]={1,3,5,7,9,2,4,6,8,10}; int *p; for(p=a;p printf("%d ",*p); printf("/n");}原创 2009-03-20 08:47:00 · 1316 阅读 · 0 评论 -
辗转相除法,求公约数和公倍数.
#includevoid main(){ int m,n,m1,n1,a; printf("输入两个正整数:/n"); scanf("%d%d",&m,&n); m1=m; n1=n; a=m1%n1; while(a!=0) { m1=n1; n1=a; a=m1%n1; } printf("最大公约数是%d./n",n1); printf("最小公倍数是%d./n",m*n/n1);}原创 2009-03-23 16:20:00 · 528 阅读 · 0 评论