Page 7 of 15
Posted: Tue May 01, 2007 8:44 pm
by gates1
please help me, this is WA
Code: Select all
var n,i,max:integer;
s:string;
a:array[1..100]of string;
begin
repeat
readln(s);
if length(s)>max then max:=length(s);
for i:=1 to length(s) do
a[i]:=a[i]+s[i];
until eof;
for i:=1 to max do
writeln(a[i]);
readln;
end.
490 PE Please help
Posted: Sun Jun 03, 2007 6:11 pm
by rhsumon
Here is my code:
#include<stdio.h>
#include<string.h>
int main()
{
//freopen("490.in", "r", stdin);
//freopen("490.out", "w", stdout);
char str[101], line[101][101];
int len,i,j,k,m_len;
k = 0;
m_len = 0;
for(i=0; i<101; i++)
for(j=0; j<101; j++)
line
[j] = NULL;
while(gets(str) != NULL){
strcpy(line[k], str);
len = strlen(line[k]);
if(m_len < len)
m_len = len;
k++;
}
for(i=0; i<m_len; i++){
for(j=k-1; j>=0; j--){
if(line[j] != 0)
printf("%c",line[j]);
}
printf("\n");
}
//printf("\n");
return 0;
}
Where is the problem??? I can't fix it.....Please anyone help.
Posted: Mon Jun 04, 2007 11:18 pm
by Jan
Search the board first. Don't open a new thread if there is one already.
Posted: Sat Jul 14, 2007 4:23 pm
by Bad Boy
Accepted, but why spaces are required
Posted: Sat Jul 14, 2007 5:07 pm
by Jan
You are checking garbage values. Initialize your array ( a[][] ) with spaces. Hope it helps.
490 help me please
Posted: Thu Aug 02, 2007 5:01 pm
by handsomepot
I'd made all the test data cotrect on the board.
But I got WA all the time.
Here is my code
#include<stdio.h>
char a[101][101];
int max;
int main()
{
int b[101];
char n;
int i=0,j=0;
int k,m,p=0;
while(scanf("%c",&n)==1)
{
if(n!='\n')
{
a[j]=n;
j++;
}
if(n=='\n')
{
b=j;
if(j>max)
max=j;
i++;
j=0;
}
}
for(m=0;m<max;m++)
for(k=i-1;k>=0;k--)
{
printf("%c",a[k][m]);
if(k==0&&m!=max-1)
printf("\n");
}
return 0;
}
Posted: Thu Aug 02, 2007 7:47 pm
by Jan
Dont open a new thread if there is one already.
wa
Posted: Fri Aug 03, 2007 2:32 am
by handsomepot
I'd made all the test data on the boardcotrect .
But I got WA all the time.
Here is my code
#include<stdio.h>
char a[101][101];
int max;
int main()
{
int b[101];
char n;
int i=0,j=0;
int k,m,p=0;
while(scanf("%c",&n)==1)
{
if(n!='\n')
{
a[j]=n;
j++;
}
if(n=='\n')
{
b=j;
if(j>max)
max=j;
i++;
j=0;
}
}
for(m=0;m<max;m++)
for(k=i-1;k>=0;k--)
{
printf("%c",a[k][m]);
if(k==0&&m!=max-1)
printf("\n");
}
return 0;
}
can someone double check this?
Posted: Sat Oct 13, 2007 10:56 am
by jjtse
It handles the above input cases exactly and it still gives me presentation error.
My current program outputs a newline at the end of output. Weird thing is, if I remove that last newline at the end of the output, it'll say wrong answer.
Code: Select all
#include <iostream>
using namespace std;
string str [101];
void printSpaces(int n){
int i;
for (i=0; i<n; i++)
cout <<" ";
}
int main(){
int maxRow = 0;
int i=0;
getline(cin, str[i]);
while (!cin.eof()){
if (maxRow < str[i].length())
maxRow = str[i].length();
i++;
getline(cin, str[i]);
}
int cols=0;
int rows = 0;
for (rows = 0; rows < maxRow; rows++){
int spacesSaved = 0;
for (cols=i; cols>=0; cols--){
if (rows < str[cols].length()){
if (spacesSaved > 0){
printSpaces(spacesSaved);
spacesSaved = 0;
}
cout << str[cols][rows];
}
else
spacesSaved ++;
}
cout << endl;
}
return 0;
}
Posted: Thu Oct 18, 2007 8:12 am
by sapnil
To jjtse
Trying this case:
Input:
Code: Select all
aaa aaa
aaa
aaa
aaa
a
aaaaaaaaaaaaaaaaaaaaaaa
Output:
Code: Select all
aaaaaa
a aaaa
a aaaa
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a a
a a
a a
** Every input line have same length.
Thanks
Keep posting
Sapnil
Posted: Thu Oct 18, 2007 4:58 pm
by jjtse
Thanks! I got ACCEPTED.
fraustatingly WA or PE Always
Posted: Sat Dec 29, 2007 5:22 pm
by mrmbdctg
Here is my code I always get WA with it
#include<stdio.h>
#include<string.h>
int main()
{
char temp [101], result[100][101];
int k=0,len=0,tempo,i,m,j;
/*freopen("a.out","w",stdout); */
while(gets(temp))
{
strcpy(result[k],temp);
k++;
tempo=strlen(temp);
if(tempo>len)
len=tempo;
}
m=0;
for(i=0;i<len;i++)
{
for(j=k-1;j>=0;j--)
{
printf("%c",result[j][m]);
if(j==0)m++;
}
if(i!=(len-1))
printf("\n");
}
return 0;
}
Thanks in advance. By the way , I always code-- to be a WA man

is my logic also completely wrong
Posted: Sat Dec 29, 2007 5:32 pm
by mrmbdctg
I have posted above code is the logic also wrong I am asking because I always getting WA

Posted: Mon Dec 31, 2007 11:54 am
by Samiul
Hi,
You are printing some garbage at the end. After correcting that try this forum,
http://online-judge.uva.es/board/viewtopic.php?t=5864
try sapnil's input, this is the one which gave me "accepted".
I think the new server got some problem with blank lines and spaces, for this it gave me a lot of trouble with this problem, and for this reason some of the input's, output's on the e-board are not correct anymore for this problem in new server.
Posted: Sat Feb 02, 2008 8:01 am
by mirage
what should be out put for this input????
nd further more will i get a WA if i put extra spaces in case like
abcd
abcde
output:
aa
bb
cc
dd
e[space]
Code: Select all
"R Jan
Ie
n
te
h
iD
ne
kc
,a
r
tt
he
es
r
eo
fn
oc
re
e
s
Ia
i
ad
m,
.
"