490 - Rotating Sentences

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Mon Mar 31, 2003 9:24 pm

Dominik: I print them and get accepted!
I was in doubt when I reviewed my code for my post in this thread, but I rechecked it, and it is so. Not even P.E. but plain AC.

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski » Tue Apr 01, 2003 8:11 am

Hmmm, that's strange ....
If I correct remember statements say, that spaces at end of line should be avoided .... (I got P.E. - maybe instead of that ?)

Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

raysa
New poster
Posts: 40
Joined: Wed Dec 18, 2002 4:23 pm
Location: Indonesia

Post by raysa » Thu Apr 03, 2003 4:54 pm

Sorry to interrupt, but I just last my WA's by replacing NULL string '\0' with whitespace...
They really make me think that they ARE right, Dominik!
Thank's to Hisoka and Little Joey... :D

Regards,
Raysa

de
New poster
Posts: 11
Joined: Sat Mar 08, 2003 3:46 pm

Problem 490

Post by de » Sat Apr 05, 2003 9:49 am

I got Wrong Answer
but I don't know why ><...

[cpp]
#include <iostream.h>
#include <string.h>
#include <stdio.h>

int main()
{
char data[101][101];
int msize;
int n,t,t2;

for (t=0 ;t<=100 ;t++)
data[0][t]=' ';

n=0;

// freopen ("482in.txt","r",stdin);

msize=0;
while (gets (data[n]))
{
if (strlen(data[n])>msize)
msize=strlen (data[n]);
n++;
for (t=0 ;t<=100 ;t++)
data[n][t]=' ';
}

for (t=0 ;t<msize ;t++)
{
for (t2=n-1 ;t2>=0 ;t2--)
cout << data[t2][t];
cout << endl;
}

return 0;
}
[/cpp]

Thanks!

afonsocsc
New poster
Posts: 34
Joined: Mon Mar 24, 2003 1:15 am
Location: Portugal, Lisbon

Post by afonsocsc » Sat Apr 05, 2003 3:09 pm

Input:
"
.
,m
da
i
aI
s
e
er
co
nf
oe
r
se
eh
tt
r
a,
ck
en
Di
h
et
n
eI
R"

your output:
Rene Decartes once said,
"Ithink,thereforeIam."

should be:
Rene Decartes once said,
"I think, therefore I am."

Try to rotate strings four times, they should be like they were in the beginning...

pcncvl
New poster
Posts: 1
Joined: Mon Aug 11, 2003 3:35 pm

490 - Rotating Sentences [WA]

Post by pcncvl » Mon Aug 11, 2003 3:38 pm

I cannot find out what is wrong with my code... can anyone help me and take a look?
Many thanks!
[c]
#include <iostream.h>
#include <stdio.h>

int main()
{
char chArr[200][200];
char **chOut;
char chIn;
int I, J;
int K, L;
int intLines;
int intLongest = 0;
bool firstchar = true;

//freopen("test_in.txt","r",stdin);
//freopen("test_out.txt","w",stdout);

for (I = 0; I < 100; I++)
{
for (J = 0; J < 100; J++)
chArr[J] = '\0';
}

I = J = 0;
intLines = 0;

while (scanf("%c",&chIn)==1)
{
if (chIn == '\t' || chIn == '\r')
continue;
if (chIn == '\n')
{
J++;
intLines++;
I = 0;
continue;
}
chArr[J] = chIn;
I++;

if (I > intLongest)
intLongest = I;
}
intLines += 1;

chOut = new char*[intLines];

for (I = 0; I < intLines; I++)
chOut = new char[intLongest];

K = L = 0;
for (I = 0; I < intLongest; I++)
{
K = 0;
for (J = intLines - 1; J >=0; J--)
{
chOut[K][L] = chArr[J];
K++;
}
L++;
}

for (I = 0; I < intLongest; I++)
{
for (J = 0; J < intLines; J++)
cout << chOut[J];
if (I != intLongest - 1)
cout << endl;
}

return 0;
}
[/c]

Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer » Tue Aug 12, 2003 4:27 am

Hello!

I've tested your program and found that it suffers from Presentation Errors. So I would suggest the following modifications:
1. Delete line 46: intLines += 1;
2. Delete line 72: if (I != intLongest - 1)

Try it and get AC!
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org

User avatar
Riyad
Experienced poster
Posts: 131
Joined: Thu Aug 14, 2003 10:23 pm
Location: BUET
Contact:

490 wa, plizzzzzzzzzzzzzzz help me :(:(:(

Post by Riyad » Thu Aug 21, 2003 9:43 pm

i am having trouble with 490, i am getting wa all the time.here is my code plizzzzzz help.
thanx in advance
Riyad
:cry: :cry: :cry: :cry: :cry: :cry: :cry:

Code: Select all

#include<stdio.h>
#include<string.h>

#define row 100
#define col 110

char input[row][col];
int index=0;

 int max_count(){

	int i ;
	int max=0;
	for(i=0;i<index;i++){
	
		if(strlen(input[i])>max){
			max=strlen(input[i]);
		
		}
		else
			continue;
	}

	
	return max;

}

void print(int max){

	int i ,j;

	for(i=0;i<max;i++){
	
		for(j=index-1;j>=0;j--){
		
			if(i>=strlen(input[j]))
				continue;
			else
				printf("%c",input[j][i]);
		
		}
		printf("\n");
	}






}







int main(){

	int max;
	freopen("input.in","rt",stdin);
	
	while(gets(input[index++])){
	
		;	
	
	
	}
	max=max_count();
	print(max);
	
	
	return 0;
}
HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN

User avatar
UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:

Post by UFP2161 » Thu Aug 21, 2003 10:26 pm

INPUT

Code: Select all

test
test test
test test test
test test
test
YOUR OUTPUT

Code: Select all

ttttt
eeeee
sssss
ttttt
   
ttt
eee
sss
ttt
 
t
e
s
t
EXPECTED OUTPUT

Code: Select all

ttttt
eeeee
sssss
ttttt
    
 ttt
 eee
 sss
 ttt
   
  t
  e
  s
  t

User avatar
Riyad
Experienced poster
Posts: 131
Joined: Thu Aug 14, 2003 10:23 pm
Location: BUET
Contact:

still wa:(:(:( plizzzzzzzzzzzzzzzzzz help

Post by Riyad » Fri Aug 22, 2003 6:51 am

i adjusted what u have told about my program . i printed a space instead of continuing when the string length is small . my program now prints the same as the sample out put of urs. but still having wa. :cry: :cry: :cry: :cry: :cry: :cry: .plizzzzzzzzzzzzzz help me .

here is my code : :cry: :cry: :cry:

Code: Select all

#include<stdio.h>
#include<string.h>

#define row 100
#define col 110

char input[row][col];
int index=0;

 int max_count(){

	int i ;
	int max=0;
	for(i=0;i<index;i++){
	
		if(strlen(input[i])>max){
			max=strlen(input[i]);
		
		}
		else
			continue;
	}

	
	return max;

}

void print(int max){

	int i ,j;

	for(i=0;i<max;i++){
	
		for(j=index-1;j>=0;j--){
		
			if(i>=strlen(input[j])){
changed here!!--------------------------------------->printf(" ");
/**************************************************/
				//continue;
			}
			else
				printf("%c",input[j][i]);
		
		}
		printf("\n");
	}






}







int main(){

	int max;
	freopen("input.in","rt",stdin);
	
	while(gets(input[index++])){
	
		;	
	
	
	}
	max=max_count();
	print(max);
	
	
	return 0;
}
thanx is advance
Riyad
HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN

slonko
New poster
Posts: 2
Joined: Tue Oct 14, 2003 4:02 pm

490 why WA???

Post by slonko » Tue Nov 25, 2003 6:20 pm

hi! i have WA whu? plz help

[c]
#include <stdio.h>
#include <string.h>

main()
{
char tab[102][102];
int spr[102];
char t;
int i=0,n,max=0;
int j=0;
t=getchar();
while(t!=EOF)
{
char s;
j=0;
while (t!='\n' && t!=EOF)
{
if (t!='\t' && t!='\r'){
tab[j]=t;
j++;
}
t=getchar();
}
s=t;
t=getchar();
tab[j]='\0';
spr=1;
i++;
}

n=i;
for (i=0;i<n;i++)
if (max<strlen(tab))
max=strlen(tab);

for (i=0;i<max+1;i++)
{
int j;
for (j=n-1;j>=0;j--)
{
if (spr[j])
{
if (tab[j]!=0)
putchar(tab[j]);
else
{
spr[j]=0;
putchar(' ');
}
}
else
putchar(' ');
}
putchar('\n');
}


}
[/c]

gcp
New poster
Posts: 6
Joined: Sat Nov 22, 2003 5:38 am
Location: Brazil
Contact:

WA, WA, WA!!

Post by gcp » Tue Dec 23, 2003 5:58 am

Why WA?
I've ever looked all posts about this problem, but none helped me.

[cpp]
#include <iostream.h>
#include <string.h>

void main()
{ char matriz[102][102];
int cont, max;

cont=0;
max=0;
while (cin.getline(matriz[cont],100,'\n'))
{ if (strlen(matriz[cont])>max) max=strlen(matriz[cont]);
cont++;
}


for (int i=0; i<max; i++)
{ for (int j=cont-1; j>=0; j--)
if (strlen(matriz[j])>i)
cout << matriz[j];
else cout << " ";
cout << endl;
}

}
[/cpp][/code]
VIVA LEOPARDO SC!!

snake79
New poster
Posts: 3
Joined: Thu Nov 20, 2003 2:53 am

i got WA on 490, can you help me?

Post by snake79 » Sun Jun 20, 2004 1:38 pm

Here is my code... i tried to substitute '\0' in the array "str" with spaces but i still get WA. I saw some topics about 490 but i didn't found where i'm wrong... can you help me?

[c]
#include <stdio.h>
#include <string.h>

main()
{
char str[103][103]={'\0'};
int i=0,j,maxl=0,k,pos;
while( fgets(str,102,stdin) )
{
pos=(strlen(str)-1);
if (pos<0) pos=0;
if (str[pos]=='\n') str[pos]='\0'; /* Erases fgets' '\n'*/
if ( maxl<strlen(str) ) maxl=strlen(str);
++i;
}
--i;

for (k=0;k<maxl;k++)
{
for(j=i;j>=0;j--)
{
printf("%c",str[j][k]);
}
printf("\n");
}
}

[/c]

Thanks in advance!

Wei
New poster
Posts: 23
Joined: Sat Jul 24, 2004 5:37 pm
Contact:

490 with WA~~~

Post by Wei » Fri Oct 29, 2004 1:14 pm

I don't know where is wrong~~
Could anybody help me???
[c]#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int i=-1,j=-1,k,l,max=0;
char ch[105][105],a;
while(scanf("%c",&a)!=EOF)
{
i++;
j=-1;
while(a!=10)
{
if(a!=9)
{
j++;
ch[j]=a;
}
scanf("%c",&a);
}
if(j>max)
max=j;
}
for(l=0;l<=max;l++)
{
for(k=i;k>=0;k--)
printf("%c",ch[k][l]);
printf("\n");
}
return 0;
}[/c]

User avatar
A1
Experienced poster
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

Post by A1 » Sun Oct 31, 2004 9:57 am

in printing section add this code:

Code: Select all

for(k=i........)
{
      if(ch[k][l]<='\0')
         ch[k][l]=' ';
      printf(.........);
}
and make your array size little bigger :o

Note: problem statement is false, about input size!! :x

Post Reply

Return to “Volume 4 (400-499)”