Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么runtime error?谢了

Posted by DavidCameron at 2017-02-11 10:37:42 on Problem 1002
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator