Number Formatting

Dev Skill archived problems can be discussed here.

Number Formatting

by MarufAhmed » Mon Dec 19, 2016 12:27 pm

prb link: http://www.devskill.com/CodingProblems/ViewProblem/194

Why WA?

My code :

#include<stdio.h>
#include<string.h>
main()
{
int t,i,j,k;
scanf("%d",&t);
char ch[] = "abcd";
char p[10][5]={"011","015","016","017","018","019"};
char p1[10][17]={"Citycell","Teletalk","Airtel","Grameenphone","Robi","Banglalink"};
for(i=0;i<t;i++)
{
char s[15],c[15];
scanf("%s",s);

if(strlen(s)!=11)
{
for(j=2;j<13;j++)
{
c[j-2]=s[j];
}
}
else
{
for(j=0;j<11;j++)
{
c[j]=s[j];
}
}
for(j=0;j<6;j++)
{
if(strcmp(p[j],c)==1)
{
printf("88");
for(k=0;k<11;k++)
printf("%c",c[k]);
printf(" %s\n",p1[j-1]);
break;
}
}



}
}
 
Posts: 3
Joined: Sun Dec 18, 2016 11:21 pm

Re: Number Formatting

by mahrahat » Wed Dec 21, 2016 2:45 am

The reason lies here:
Code: Select all
strcmp(p[j],c)==1

Read carefully on strcmp.
Lets
• search through previous topics before posting a new topic
• include link to problem (or at least problem number)
• write code snippets inside [code] [ /code] tags
 
Posts: 48
Joined: Thu Nov 24, 2016 9:11 pm
Location: Bangladesh


Who is online
Users browsing this forum: No registered users and 1 guest
cron