It was really a chilly mistake.
- Code: Select all
Accepted
keep posting.
Moderator: Board moderators
newton wrote:why Compilation Error?
And also say is my algorithm correct? will the code be accepted after correction?
int comp(const void *a,const void *b) {int binSearch(char *p,int n){got ac
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string,int>M;
typedef struct{
char final[205];
}data;
data A[100005];
int main(){
int i,cnt,j,k;
char str[205],tempa[200],tempb[200];
//freopen("i.txt","r",stdin);
cnt=0;
while(gets(str)){
if(!strcmp(str,""))
break;
i=0;
while(1){
if(str[i]==' ')
break;
i++;
}
for(j=0;j<i;j++)
tempa[j]=str[j];
tempa[j]='\0';
strcpy(A[cnt].final,tempa);
for(k=0,j=i+1;str[j];j++,k++)
tempb[k]=str[j];
tempb[k]='\0';
M[tempb]=cnt;
cnt++;
memset(tempa,NULL,sizeof(tempa));
memset(tempb,NULL,sizeof(tempb));
memset(str,NULL,sizeof(str));
}
while(gets(str)){
if(M[str]){
printf("%s\n",A[M[str]].final);
}
else
printf("eh\n");
}
return 0;
}ACCEPTED
Users browsing this forum: Bing [Bot] and 1 guest