## 11946 - Code Number

Moderator: Board moderators

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm

### 11946- Code Number

I am getting wrong answer... What is th tricky case?
If you have determination, you can do anything you want.... iriz7482
New poster
Posts: 15
Joined: Mon Apr 04, 2011 3:18 pm

### Re: 11946- Code Number

I also got W.A many times because I forgot to add \n in the line

Code: Select all

``scanf("%d\n",&n);``
n is number of test cases.
Also remember not to print a blank line in the last test case.
Hope this help naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm

### Re: 11946- Code Number

Still WA.... here is my code...

Code: Select all

``````// Code Removed after AC.. :D
``````
If you have determination, you can do anything you want.... rafay-hasan
New poster
Posts: 4
Joined: Sat Jul 03, 2010 1:04 pm

### 11946- Code Number

I am getting TLE for this problem. can anyone tell me whats wrong with my code.

#include<stdio.h>
#include<string.h>
char a;
int c,i,j,found,got,t,test,line;

int main()
{
scanf("%d",&test);
getchar();
for(t=1;t<=test;t++)
{
while(1)
{
gets(a);
c=strlen(a);
if(c==0)
break;
found=got=0;
found=check();
for(i=0;i<c;i++)
{
if(a=='1')
a='I';
else if(a=='2')
a='Z';
else if(a=='3')
a='E';
else if(a=='4')
a='A';
else if(a=='5')
a='S';
else if(a[i]=='6')
a[i]='G';
else if(a[i]=='7')
a[i]='T';
else if(a[i]=='8')
a[i]='B';
else if(a[i]=='9')
a[i]='P';
else if(a[i]=='0')
a[i]='O';
printf("%c",a[i]);
}
printf("\n");
}
printf("\n");
}
return 0;
}

robot
New poster
Posts: 29
Joined: Sun May 24, 2009 8:39 pm

### Re: 11946- Code Number

Hi rafai
u arise some problem....
2.problem says print a blank line between test case not at all so be careful and edit ur blank line
3.garbage variable or function be delete.......

ASU(SUST) Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

### Re: 11946- Code Number

The problem description's encode/decode message for this problem is wrong -- use the sample input/output. It uses some 2s as Z's or something.

shaon_cse_cu08
New poster
Posts: 50
Joined: Tue May 25, 2010 9:10 am
Contact:

### Re: 11946- Code Number

Hai i m confused with the blank line instance... I have tried every possible way But it failed...Plz this is my code...Some1 who have AC plzz help me....This one is making me creazy.....  Code: Select all

``````Deleted After AC....Insted of considering line by line..i was considering the whole case....
``````
I'll keep holding on...Until the walls come tumbling down...And freedom is all around ..... mostafa_angel
New poster
Posts: 23
Joined: Sun Oct 04, 2009 12:03 pm

### Re: 11946- Code Number

hi...
I got WA ! But I cant not figure it out...
Can Anybody help...

my code :

Code: Select all

``````AC... :)
``````

snape
New poster
Posts: 5
Joined: Sat Dec 03, 2011 4:18 pm

### 11946- Code Number

i got WA && also dont under stand input system,plz help
my code is here:
#include<stdio.h>

char a;
int c,i,j,found,got,t,test,line,w=0;

int main()
{
scanf("%d",&test);
getchar();
while(test--)
{

while(gets(a) && (a!='\n'))
{

if(c==0)
break;

for(i=0;a!='\0';i++)
{
if(a=='1')
a='I';
else if(a=='2')
a='Z';
else if(a=='3')
a='E';
else if(a=='4')
a='A';
else if(a=='5')
a[i]='S';
else if(a[i]=='6')
a[i]='G';
else if(a[i]=='7')
a[i]='T';
else if(a[i]=='8')
a[i]='B';
else if(a[i]=='9')
a[i]='P';
else if(a[i]=='0')
a[i]='O';
else
{}
}
printf("%s\n",a);
}

}
return 0;
}

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Contact:

### 11946- Code Number WA why?

I am also WA. I do not know why? Please, give some critical test cases, please. Please.....
Here is my code.

Code: Select all

``````#include <cstdio>
#include <cstring>
#include <cctype>

int main()
{
int T,t,f=0;
//freopen("in-11946.txt","r",stdin);
//freopen("11946.txt","w",stdout);
scanf("%d\n",&T);

for(t=1 ; t<=T ; t++)
{
char ch={'\0'};
while(gets(ch))
{
int len=strlen(ch);
if(f==1 || ch=='\0' || ch=='\n')
{printf("\n\n"); f=0;}
for(int i=0 ; i<len ; i++)
{
if(((ch[i]!=' ' || ch[i]=='.') && ch[i+1]=='\0'))
{
f=1;
}

if(isdigit(ch[i]))
{
if(ch[i]=='0')
printf("O");
else if(ch[i]=='1')
printf("I");
else if(ch[i]=='2')
printf("Z");
else if(ch[i]=='3')
printf("E");
else if(ch[i]=='4')
printf("A");
else if(ch[i]=='5')
printf("S");
else if(ch[i]=='6')
printf("G");
else if(ch[i]=='7')
printf("T");
else if(ch[i]=='8')
printf("B");
else if(ch[i]=='9')
printf("P");
}
else
printf("%c",ch[i]);

}

}
}
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11946- Code Number

Your output doesn't match the sample output, it should have the same newlines.
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11946- Code Number

snape, c is uninitialized so it equals 0. This statement causes your program to not print anything:
if(c==0)
break;
Check input and AC output for thousands of problems on uDebug!

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Contact:

### Re: 11946- Code Number

Hi,
brianfry713
I want to thank you from my heart for your helping.
Actually, I can't spend time on uva problem or any online program because I am busy at Programming camp 2012 (BUET). You know I am new coder so I am learning programming. This camp period is 9:00 AM to 7:00 PM (almost whole day).
So, I will try your test cases and suggestion after this camp.
Thanks again from my heart.

uvasarker
Learning poster
Posts: 96
Joined: Tue Jul 19, 2011 12:19 pm
Contact:

### Re: 11946- Code Number

Thanks a lot.
Thanks a lot.
Thanks a lot boss.
Finally, I got it AC.

alfar01
New poster
Posts: 2
Joined: Tue Feb 14, 2012 3:27 pm
Location: Tainan,Taiwan

### 11946 - Code Number

Why I got WA with my code?

Code: Select all

``````#include<stdio.h>
#include<string.h>
int main()
{
freopen("11946.in","r",stdin);
freopen("11946.out","w",stdout);
int i,j,stat,part=1,flag1=1,flag2=1;
char c,ans[]={"OIZEASGTBP"};
scanf("%d\n",&stat);
while(part<=stat){
flag1?flag1=0:putchar('\n');
for(i=0;;i++){gets(c[i]);if(c[i]=='\0')break;}
for(i=0;c[i]!='\0';i++)
for(j=0;c[i][j]!='\0';j++)
if(c[i][j]>='0'&&c[i][j]<='9')
c[i][j]=ans[c[i][j]-'0'];
for(i=0;;i++){
if(c[i]=='\0')break;
flag2?flag2=0:putchar('\n');
printf("%s",c[i]);
}
part++;
}
return 0;
}
``````