Page 1 of 2
10894 - Save Hridoy
Posted: Wed Aug 10, 2005 1:55 am
by htl
I wanna ask a small problem in the program. It's about the method in printing the string of length n. Let me assume that n<6.
Method 1
s[6]="*****";
s[n]='\0';
printf("%s",s);
s[n]='*';
Method 2
for(x=0;x<n;x++)
putchar('*');
The method 1 got WA and the method 2 got AC. But I wanna know why.
Posted: Wed Aug 10, 2005 1:57 am
by Abednego
Are you sure that n<6? I don't think there can be a difference between the two programs unless n>=6.
And i hope you mean
char s[6] = "*****";
instead of
s[6] = "*****";
Posted: Wed Aug 10, 2005 2:35 am
by htl
I know in this problem I have to declare a s[51]. And I set its value as a string of consecutive '*'s or '.'s. I just wanna know what's the difference between them.
Posted: Sat Aug 13, 2005 9:25 am
by J&Jewel
Hello dears I have got a problem about this problem...plz help me...
My out put is seems ok...but when vertically printing the output did not fixed in a line so I can't understend...my output...how can I make the output font small...so that it fixed in the range..?
Posted: Sun Aug 14, 2005 8:27 pm
by ibrahim
J&Jewel wrote:Hello dears I have got a problem about this problem...plz help me...
My out put is seems ok...but when vertically printing the output did not fixed in a line so I can't understend...my output...how can I make the output font small...so that it fixed in the range..?
You better take the output to file.

first make the input file. Let a.in
now run:
You will get the out on a.out file.
Btw, you have to use command line on windows or terminal on linux.

Posted: Sun Aug 14, 2005 8:35 pm
by ibrahim
Input:
Output:
Code: Select all
**********....******....**......**..**********......**......**..**********..**********..******......**********..**......**
**********....******....**......**..**********......**......**..**********..**********..******......**********..**......**
**..........**......**..**......**..**..............**......**..**......**......**......**....**....**......**....**..**..
**..........**......**..**......**..**..............**......**..**......**......**......**....**....**......**....**..**..
**********..**********..**......**..******..........**********..**********......**......**......**..**......**......**....
**********..**********..**......**..******..........**********..**********......**......**......**..**......**......**....
........**..**......**....**..**....**..............**......**..**..**..........**......**....**....**......**......**....
........**..**......**....**..**....**..............**......**..**..**..........**......**....**....**......**......**....
**********..**......**......**......**********......**......**..**....****..**********..******......**********......**....
**********..**......**......**......**********......**......**..**....****..**********..******......**********......**....
**********
**********
**........
**........
**********
**********
........**
........**
**********
**********
..........
..........
..******..
..******..
**......**
**......**
**********
**********
**......**
**......**
**......**
**......**
..........
..........
**......**
**......**
**......**
**......**
**......**
**......**
..**..**..
..**..**..
....**....
....**....
..........
..........
**********
**********
**........
**........
******....
******....
**........
**........
**********
**********
..........
..........
..........
..........
..........
..........
**......**
**......**
**......**
**......**
**********
**********
**......**
**......**
**......**
**......**
..........
..........
**********
**********
**......**
**......**
**********
**********
**..**....
**..**....
**....****
**....****
..........
..........
**********
**********
....**....
....**....
....**....
....**....
....**....
....**....
**********
**********
..........
..........
******....
******....
**....**..
**....**..
**......**
**......**
**....**..
**....**..
******....
******....
..........
..........
**********
**********
**......**
**......**
**......**
**......**
**......**
**......**
**********
**********
..........
..........
**......**
**......**
..**..**..
..**..**..
....**....
....**....
....**....
....**....
....**....
....**....
Please some one check my output.
Posted: Sun Aug 14, 2005 8:55 pm
by ibrahim
Strange, i submit my previous code with a very small array size and got wrong answere.
And then make the array size more bigger and got RE (Strange

)
And last submit with more bigger array and got accept (PE)
Then my question,
1. Why i got wrong answere insted of RE?
2. Why PE?
I have two new line in every cases execpt last.
Posted: Wed Aug 17, 2005 9:36 am
by J&Jewel
Thkx Ibrahim I have got AC I have an extra doted lines after Y...so silly mistake...And I can found it by print it to file....Thanks again...
I Think that u print the two new line after last case too....
Posted: Thu Aug 18, 2005 5:35 am
by ibrahim
J&Jewel wrote:Thkx Ibrahim I have got AC I have an extra doted lines after Y...so silly mistake...And I can found it by print it to file....Thanks again...
I Think that u print the two new line after last case too....
Great to hear that, my help works for you.
Btw, I skip the last two new line using flag. So i don't think that, i got PE for the new line.

Posted: Thu Aug 18, 2005 9:42 am
by J&Jewel
Ibrahim, U didn't understant.....
I say U got the P.E for do not print the new line after last case...
U should print two new line after last case too....then u can got the AC without P.E........Best of luck...
10894 - Save Hridoy
Posted: Thu Aug 25, 2005 2:21 pm
by sunmoonstar_love
/*
I have submitted my code on many OJ, it can pass compiler,
but I got CE , why??
I'm not familiar with UVA's compiler
*/
#include<stdio.h>
void output2(char s[][6],int n, int r, int c)
{
char *tmp = new char[n*c+10];
int i,j,k,t;
for(i = 0; i < r; i++)
{
t = 0;
for(j = 0; j < c; j++)
{
for(k = 0; k < n; k++)
{
tmp[t++] = s[j];
}
}
tmp[t] = 0;
for(j = 0; j < n; j++)
printf("%s\n",tmp);
}
//printf("\n");
}
void output1(char s[][62],int n, int r, int c)
{
char *tmp = new char[n*c+10];
int i,j,k,t;
for(i = 0; i < r; i++)
{
t = 0;
for(j = 0; j < c; j++)
{
for(k = 0; k < n; k++)
{
tmp[t++] = s[j];
}
}
tmp[t] = 0;
for(j = 0; j < n; j++)
printf("%s\n",tmp);
}
printf("\n");
}
char s1[5][62] = {"*****..***..*...*.*****...*...*.*****.*****.***...*****.*...*",
"*.....*...*.*...*.*.......*...*.*...*...*...*..*..*...*..*.*.",
"*****.*****.*...*.***.....*****.*****...*...*...*.*...*...*..",
"....*.*...*..*.*..*.......*...*.*.*.....*...*..*..*...*...*..",
"*****.*...*...*...*****...*...*.*..**.*****.***...*****...*.."};
char s2[61][6] = {
"*****",
"*....",
"*****",
"....*",
"*****",
".....",
".***.",
"*...*",
"*****",
"*...*",
"*...*",
".....",
"*...*",
"*...*",
"*...*",
".*.*.",
"..*..",
".....",
"*****",
"*....",
"***..",
"*....",
"*****",
".....",
".....",
".....",
"*...*",
"*...*",
"*****",
"*...*",
"*...*",
".....",
"*****",
"*...*",
"*****",
"*.*..",
"*..**",
".....",
"*****",
"..*..",
"..*..",
"..*..",
"*****",
".....",
"***..",
"*..*.",
"*...*",
"*..*.",
"***..",
".....",
"*****",
"*...*",
"*...*",
"*...*",
"*****",
".....",
"*...*",
".*.*.",
"..*..",
"..*.."};
int main()
{
int n;
while(scanf("%d",&n) && n)
{
if(n < 0)
{
output2(s2, -n, 61, 5);
}
else
{
if(n > 0)
{
output1(s1, n, 5,61);
}
}
}
return 0;
}
Posted: Thu Aug 25, 2005 3:33 pm
by Cho
Did you submit it as C?
Posted: Fri Aug 26, 2005 1:19 am
by Abednego
Check your email. The judge replies with the exact error message.
Misunderstood
Posted: Tue Nov 29, 2005 5:54 am
by worm3959
sunmoonstar_love wrote:/*
I am not sure if you understood what i meant, but i know that was not it.
Re: Misunderstood
Posted: Sat Dec 10, 2005 4:08 pm
by Martin Macko
worm3959 wrote:
I am not sure if you understood what i meant, but i know that was not it.
_________________
casinos no deposit online casinos
Sigh! another spammer
