Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我快要疯掉了,到底什么是Runtime error啊???恳请名位高手帮帮忙啊 程序怎么调试都没问题,但就是Runtime error! 到底什么是Runtime error啊???我都快郁闷死了!!! 下面是我的C程序代码: #include<stdio.h> #include<malloc.h> #include<string.h> char f(char c) { switch(c) { case '1':return '1'; case '2': case 'A': case 'B': case 'C':return '2'; case '3': case 'D': case 'E': case 'F':return '3'; case '4': case 'G': case 'H': case 'I':return '4'; case '5': case 'J': case 'K': case 'L':return '5'; case '6': case 'M': case 'N': case 'O':return '6'; case '7': case 'P': case 'R': case 'S':return '7'; case '8': case 'T': case 'U': case 'V':return '8'; case '9': case 'W': case 'X': case 'Y':return '9'; case '0':return '0'; case '-':return '#'; case '\n':return '\0'; default:printf("Input error!\a");exit(0); } } void sort(char *s,long n) { char *t; int i,j; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(strcmp(s+9*i,s+9*j)>0) { strcpy(t,s+9*i); strcpy(s+9*i,s+9*j); strcpy(s+9*j,t); } } void main() { long n,t=0; register long i; int j=0,flag=1,*fl; char c='\0',*s; scanf("%ld",&n); getchar(); s=(char *)malloc(9*n); fl=(int *)malloc(n*sizeof(long)); for(i=0;i<n;i++)fl[i]=0; for(i=0;i<n;i++) { while(c!='\n') { if(j==3)s[9*i+j++]='-'; c=getchar(); if((s[9*i+j]=f(c))!='#')j++; } c='\0'; j=0; } sort(s,n); for(i=0;i<n-1;i++) { if(fl[i]==1)continue; for(j=i+1;j<n;j++) if(!strcmp(s+9*i,s+9*j)) { t++; fl[j]=1; } if(!t)continue; flag=0; for(j=0;j<8;j++) putchar(s[9*i+j]); printf(" %ld\n",t+1); t=0; } if(flag)printf("No duplicates.\n"); free(s); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator