【求大神帮忙改改错】c语言二级题
程序代码:
#include<stdio.h> int comp(char *a,char *b) { int i=0,j=0,k; while(b[i]!='\0') { if(b[i]=!a[j])i++; if(b[i]==a[j]) {i++;j++;} } if(a[j]=='\0')return 1; return 0; } void fcount(int data[],int ct,int x[]) { int i,j,t; char s[10][10]; for(i=0;i<ct;i++) { j=0;t=data[i];printf("%10d\n",i); while(t) { s[i][j++]=t%10+'0'; t/=10; } s[i][j]='\0';/**/puts(s[i]); } for(i=0;i<ct;i++) for(j=0;j<ct;j++) {puts(s[i]); if(comp(s+i,s+j))x[i]++;} } main() { int a[]={21,3,15,35,315,121,31,1,2115,2},res[10]={0},i,ct=10; FILE *fp; fp=fopen("T:\\myf2.out","w"); fcount(a,ct,res); for(i=0;i<ct;i++) {printf("%5d",res[i]);fprintf(fp,"%5d",res[i]);} fclose(fp); }