Posted: Tue Mar 14, 2006 4:19 pm
i don't know
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;
}
Yes you are right acorrding to my AC programd31mOZ wrote:The last output don't should be:
for ---> as..
this --->..sa
???????
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;
}
Code: Select all
bla blob blub
123... 0.98
Code: Select all
bla blob blub
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;
}
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;
}