这个是第十周的
bupt0813吧
全部回复
仅看楼主
level 1
#include
#include
int findrow(int n,int row){ if (row >= 2) return row-1; else if (row == 1) return n;}int findcol(int n,int col){ if (col <= n-1) return col+1; else if (col == n) return 1; }main(){ int n,sqrt[16][16]={0},element=1; int col,row,i,j; printf("enter n(n=1 to 15):"); scanf("%d",&n); row = 1; col = n/2+1; sqrt[row][col]=1; for (element=2;element<=n*n;element++) { if (sqrt[findrow(n,row)][findcol(n,col)] == 0) { row = findrow(n,row); col = findcol(n,col); sqrt[row][col] = element; } else if (sqrt[findrow(n,row)][findcol(n,col)] != 0) { row++; sqrt[row][col] = element; } } printf("\n"); for (i=1;i<=n;i++) { for(j=1;j<=n;j++) if(sqrt[i][j]!=0) printf("%d\t",sqrt[i][j]); printf("\n"); } system("pause"); return 0; }
2008年12月15日 09点12分 1
level 1
#include
#include
main(){ int result[30][30]={0}; int n,row,col,counter; printf("请输入要打印的行数:\n"); scanf("%d",&n); for (row=1;row<=n;row++) { result[row][1]=1; result[row][row]=1; } for (row=2;row<=n;row++) for (col=2;col<=n;col++) result[row][col] = result[row-1][col] + result[row-1][col-1]; for (row=1;row<=n;row++) {for (col=1;col<=n;col++) if (result[row][col]!=0) printf("%d\t",result[row][col]); printf("\n"); } system("pause"); return 0; }
2008年12月15日 09点12分 2
level 1
第二道题柴✿的做法更强大……
2008年12月15日 09点12分 3
level 0
#include
#include
#include
int* lcount;int* ncount;int* scount;int* ocount;char* str;void statistics(char* str,int* lcount,int* ncount,int* scount,int* ocount){ while (*str != '\0') { if ((*str>='a'&&*str<='z')||(*str>='A'&&*str<='Z')) (*lcount)++; else if (*str>='0'&&*str<='9') (*ncount)++; else if (*str==' ') (*scount)++; else (*ocount)++; str++; } }main(){ char string[100]={0}; int letter=0,number=0,space=0,others=0; printf("input string:\n"); gets(string); statistics(string,&letter,&number,&space,&others); printf("letter:%d number:%d space:%d others:%d\n",letter,number,space,others); system("pause"); return 0; }这次是IP☭
2008年12月15日 12点12分 4
1