10894 - Save Hridoy
Moderator: Board moderators
10894 - Save Hridoy
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.
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.
-
- Experienced poster
- Posts: 149
- Joined: Mon Feb 07, 2005 10:28 pm
- Location: Northern University, Bangladesh
- Contact:
You better take the output to file.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..?

first make the input file. Let a.in
now run:
Code: Select all
a.exe <a.in >a.out
Btw, you have to use command line on windows or terminal on linux.

-
- Experienced poster
- Posts: 149
- Joined: Mon Feb 07, 2005 10:28 pm
- Location: Northern University, Bangladesh
- Contact:
Input:
Output:
Please some one check my output.
Code: Select all
2
-2
0
Code: Select all
**********....******....**......**..**********......**......**..**********..**********..******......**********..**......**
**********....******....**......**..**********......**......**..**********..**********..******......**********..**......**
**..........**......**..**......**..**..............**......**..**......**......**......**....**....**......**....**..**..
**..........**......**..**......**..**..............**......**..**......**......**......**....**....**......**....**..**..
**********..**********..**......**..******..........**********..**********......**......**......**..**......**......**....
**********..**********..**......**..******..........**********..**********......**......**......**..**......**......**....
........**..**......**....**..**....**..............**......**..**..**..........**......**....**....**......**......**....
........**..**......**....**..**....**..............**......**..**..**..........**......**....**....**......**......**....
**********..**......**......**......**********......**......**..**....****..**********..******......**********......**....
**********..**......**......**......**********......**......**..**....****..**********..******......**********......**....
**********
**********
**........
**........
**********
**********
........**
........**
**********
**********
..........
..........
..******..
..******..
**......**
**......**
**********
**********
**......**
**......**
**......**
**......**
..........
..........
**......**
**......**
**......**
**......**
**......**
**......**
..**..**..
..**..**..
....**....
....**....
..........
..........
**********
**********
**........
**........
******....
******....
**........
**........
**********
**********
..........
..........
..........
..........
..........
..........
**......**
**......**
**......**
**......**
**********
**********
**......**
**......**
**......**
**......**
..........
..........
**********
**********
**......**
**......**
**********
**********
**..**....
**..**....
**....****
**....****
..........
..........
**********
**********
....**....
....**....
....**....
....**....
....**....
....**....
**********
**********
..........
..........
******....
******....
**....**..
**....**..
**......**
**......**
**....**..
**....**..
******....
******....
..........
..........
**********
**********
**......**
**......**
**......**
**......**
**......**
**......**
**********
**********
..........
..........
**......**
**......**
..**..**..
..**..**..
....**....
....**....
....**....
....**....
....**....
....**....
-
- Experienced poster
- Posts: 149
- Joined: Mon Feb 07, 2005 10:28 pm
- Location: Northern University, Bangladesh
- Contact:
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.
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.
-
- Experienced poster
- Posts: 149
- Joined: Mon Feb 07, 2005 10:28 pm
- Location: Northern University, Bangladesh
- Contact:
Great to hear that, my help works for you.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....
Btw, I skip the last two new line using flag. So i don't think that, i got PE for the new line.

-
- New poster
- Posts: 13
- Joined: Wed Aug 24, 2005 8:16 pm
10894 - Save Hridoy
/*
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;
}
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;
}
I'm from China
Misunderstood
I am not sure if you understood what i meant, but i know that was not it.sunmoonstar_love wrote:/*
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
Re: Misunderstood
Sigh! another spammerworm3959 wrote: I am not sure if you understood what i meant, but i know that was not it.
_________________
casinos no deposit online casinos
