题1:出现次数最多的数
#include
int i,j, n, s; int t = 1;
int a[10001] = {0}; scanf(\
for (i = 0; i < n; i++) {
scanf(\下标为输入值,每个数组值为输入频数 a[s]++;
if (a[s] > a[t]) t=s;
if (a[s] == a[t]) t=(s printf(\ return 0; } 题2:ISBN号码 #include int sum=0; char a[13] = {'\\0'}; gets(a); sum = (a[0] - '0')*1 + (a[2] - '0') * 2 + (a[3] - '0') * 3 + (a[4] - '0') * 4 + (a[6] - '0') * 5 + (a[7] - '0') * 6 + (a[8] - '0') * 7 + (a[9] - '0') * 8 + (a[10] - '0') * 9; if ((sum == a[12]-'0')||(sum==10&&a[12]=='X')) //注意正确情况几种类型 { printf(\ } else { if (sum == 10) a[12] = 'X'; else a[12] = sum + '0'; puts(a); } return 0; } 题3:相反数 #include int i, j, n,t=0; int a[501]; scanf(\ for (i = 0; i < n; i++) { scanf(\ } for (i = 0; i < n-1; i++) { for (j = i + 1; j < n; j++) { if (a[i] + a[j] == 0) t++; } } printf(\ return 0; } 题4:窗口 #include typedef struct window1{ int x1,x2,y1,y2,order; } window; void Inputwindow(window ws[],int n) { int i; for(i=1;i<=n;i++) { scanf(\ ws[n-i].order=i; } } int getpos(window ws[],int n,int x,int y) { int i; for(i=0;i if(x>=ws[i].x1&&x<=ws[i].x2&&y>=ws[i].y1&&y<=ws[i].y2) { return i; } } return -1; } void movewindow(window ws[],int n,int pos) { window w=ws[pos]; int i; for(i=pos-1;i>=0;i--) { ws[i+1]=ws[i]; } ws[0]=w; } int main() { int i,n,m,x,y,pos; scanf(\ window ws[n]; Inputwindow(ws,n); for(i=0;i scanf(\ pos=getpos(ws,n,x,y); if(pos==-1){ printf(\ } else{ printf(\ movewindow(ws,n,pos); } } return 0; } 题5:相邻数对 #include int main() { int i, j, n,t=0; int a[1001]; scanf(\ for (i = 0; i < n; i++) { scanf(\ } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (abs(a[i] - a[j]) == 1) t++; } } printf(\ return 0; } 题6:画图 #include int i, j, n,k, t = 0; int a[101][4]; scanf(\ for (i = 0; i < n; i++) { scanf(\ } for (i = 0; i < 101; i++) { for (j = 0; j < 101; j++) { for (k = 0; k < n; k++) { if (j >= a[k][0] && j = a[k][1] && i if (k < n) t++; } } printf(\ return 0; } 题7:门禁系统 #include int i, n, s = 0; int a[1001] = { 0 }; scanf(\ for (i = 0; i < n; i++) { scanf(\ a[s]++; printf(\ } return 0; } 题8:z字形扫描 #include int i, j, k, n; int a[500][500]; scanf(\ for (i = 0; i for (j = 0; j scanf(\ } } for (k = 0; k<2 * n - 1; k++) { for (i = 0; i for (j = 0; j if (i + j == k)