Page 4 of 9

Posted: Tue Mar 14, 2006 4:19 pm
by sds1100
i don't know

483 PE

Posted: Tue Mar 14, 2006 6:22 pm
by Artikali
483 PE
i deleted all white spaces.
what i should do more to get AC.

Posted: Wed Mar 15, 2006 7:57 am
by emotional blind
you cant delete all white space,
when some white spaces are needed for the output to get accepted
you should remove unnecessary white spaces and
unnecessery blank lines.. ok?

Posted: Mon May 08, 2006 7:47 am
by d31mOZ
The last output don't should be:

for ---> as..
this --->..sa

???????

483 WHY WA???

Posted: Mon May 08, 2006 8:04 am
by d31mOZ
I submit this code and i get WA, WHY??? It's a problem so easy!!!!!!

Code: Select all

#include <stdio.h>

//483

int main()
{
        char c, s[100]; int cant = 0;
        while ((c = getchar()) != EOF)
        {
                if (c != '\n')
                {
                        if (c != ' ')
                        {
                                s[cant++] = c;
                        } else
                        {
                                for (int i = cant - 1; i > -1; i--)
                                        printf("%c", s[i]);
                                cant = 0;
                                printf(" ");
                        }
                }
                else
                {
                        for (int i = cant - 1; i > -1; i--)
                                printf("%c", s[i]);
                        printf("\n");
                        cant = 0;
                }
        }
        return 0;
}

Posted: Tue May 09, 2006 9:45 pm
by Dave
Have you tested it with different inputs and outputs before submitting.

Try putting the sample input in a file in the same directory as the executable. Then run

'YOUR PROGRAM NAME' < 'INPUT FILE' > 'OUTPUT FILE'

and see if you get the same as the sample output.

Posted: Thu May 11, 2006 5:33 am
by neno_uci
Try to increase your array size, I used 10000000 chars but I guess 1000000 will do..., good luck,

Yandry.

Posted: Thu May 11, 2006 5:38 am
by neno_uci
d31mOZ wrote:The last output don't should be:

for ---> as..
this --->..sa

???????
Yes you are right acorrding to my AC program :D

Posted: Mon May 15, 2006 12:03 am
by d31mOZ

483 PE Help PLZ

Posted: Sun Jun 18, 2006 12:24 pm
by thomas1016
Can you guys tall me why it is PE???

Code: Select all

#include <iostream>
#include <string> 
using namespace std;
int main(void){
    int i,u,j;
    string a;
    while(getline(cin,a)){
                          if(a==""){continue;}
                          i=0;                
                          //cout<<a.length()<<endl;
                          while(i<a.length()){
                          
                        //  cout<<a.length()<<endl;1
                          for(u=i;a[u]!=' ' && u<=a.length();u++);
                          //cout<<a<<endl;
                          //system("pause");
                        //  cout<<i;
                        j=u-1;
                        if(j==a.length()){
                                         j--;
                                         }
                          for(;j>=i;j--){
                                              cout<<a[j];
                                              }
                         
                          if(u-1!=a.length()){
                                            cout<<a[u];
                                            
                                            }
                          i=u+1;
                          }
                          cout<<endl;
                          }




    //system("pause");
    return 0;
    }




Posted: Wed Jul 26, 2006 4:02 pm
by BenderBendingRodriguez
I have two questions to this problem:

1.) What if there is one or more blank lines in the input?

Code: Select all

bla blob blub


123... 0.98
2.) what if there are more than one white space characters between words in a line?

Code: Select all

bla                                   blob                                  blub                              

THX in advance! :)

483 why WA , plz help me !!

Posted: Fri Aug 04, 2006 11:32 am
by alfreadx

Code: Select all

#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main()
{
        int i,len;
        string str;
        stack<char> x;

        while(getline(cin,str)){
                if(cin.eof())   break;

                for(i=0; i <= str.length(); ++i){
                        if(str[i] == ' ' || str[i] == '\0'){
                                while(!x.empty()){
                                        cout << x.top() ;
                                        x.pop();
                                }
                                if(str[i] != '\0')      cout << " ";
                                else    cout << endl;
                        }
                        else    x.push(str[i]);
                }

        }
		
        return 0;
}

why wa ?? i can't find bug. thanks.

Posted: Fri Aug 04, 2006 6:52 pm
by Darko
When they say "whitespace" instead of "space" that means that they will use any whitespace (I check for '\t' and '\b' on top of those that you check).

thx

Posted: Sat Aug 05, 2006 8:20 am
by alfreadx
thank you.
i got AC bot PE.
that's ok.

483. W.A, Who can advice me?

Posted: Tue Aug 15, 2006 3:46 pm
by mosaick2
I have tested all sample that I could find below articles.
And I have passed the testcases.
BUT, online-judge give me W.A(Wrong Answer)
Frankly, I believe online-judge. So I think I have a fault in my program.
Who can give advice me aboue this?
Thankx, your help. : )

Code: Select all

#include <string>
#include <cstring>
#include <iostream>
//#include <fstream>
#include <stack>
using namespace std;

int main()
{
//	ifstream fin("input.txt");
	stack<char> stk;
	string str;
	while (getline(cin, str)) {
		for (int i  = 0; i <= str.length(); i++) {
			if (str[i] != ' ' && str[i] != '\t' && str[i] != '\0') {
				stk.push(str[i]);
			}
			else {
				while (!stk.empty()) {
					cout << stk.top(); 
					stk.pop();
				}
				if (str[i] == ' ')
					cout << ' ';
				else if (str[i] == '\t')
					cout << '\t';
				else if (str[i] == '\0')
					cout << endl;
			}
		}
	}
	return 0;
}