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?谢了#include<stdio.h> #include<stdlib.h> #include<string.h> char map[]="22233344455566677778889999"; int n=0; char parsed[100][9]; int compare(const void* elem1,const void* elem2) { return(strcmp((char*)elem1,(char*)elem2)); } void parse(char* str) { char* p=str; int i=0; while(*p!='\0') { if(i=3) { parsed[n][i]='-'; i++; continue; } if(*p>='A'&&*p<='Z') parsed[n][i]=map[*p-'A']; i++; p++; } *p='\0'; n++; } int main() { int t; scanf("%d",&t); char* str; while(t-->0) { scanf("%s",str); parse(str); } qsort(parsed,t,9,compare); for(int i=0,j=1;i<t;i++) { if(strcmp(parsed[i],parsed[i+1])==0) { i++; j++; } printf("%s",parsed[i]); printf(" %d",j); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator