asdf
By: asdf | Date: Nov 29 2007 07:52 | Format: C++ | Expires: never | Size: 2.47 KB | Hits: 1276
- #include <cstdlib>
- #include <iostream>
- #include <stack>
- #include <fstream>
- #include <queue>
- using namespace std;
- int main()
- {
- queue<string> q;
- stack<char> s;
- stack<char> s2;
- stack<char> s3;
- ifstream infile;
- ofstream outfile;
- char ch;
- char j;
- string str;
- string sent;
- // int y; debugging purposes
- string k;
- infile.open("input5.txt");
- outfile.open("output5.txt");
- if(!infile)
- {
- cerr<< "NO FILE!!!!!!n";
- system("PAUSE");
- return 1;
- }
- while(getline(infile,str))
- {
- q.push(str); // queue of sentence
- }
- while(!q.empty())
- {
- sent = q.front(); // sets sent to first sentence
- // y = sent.size(); // checks size of first sentence
- // cout << y << endl;
- for (int m=0;m<sent.length();m++)
- {
- s.push(sent[m]); // puts first sentence into stack
- }
- while(!s.empty())
- {
- if(ispunct(s.top())) //finds punctuations and adds them to k
- {
- j = s.top(); //if punct, set j to punct
- k = (k +=j);
- s2.push(' ');
- }
- else
- s2.push(s.top());
- s.pop();
- }
- j = k[0];
- while(!s2.empty())
- {
- if(isspace(s2.top()))
- {
- s3.push(j);
- }
- else
- s3.push(s2.top());
- s2.pop();
- } //?lleh?eht??woh
- while(!s3.empty())
- {
- s.push(s3.top());
- s3.pop();
- } //how??the?hell?
- while(!s.empty())
- {
- cout << s.top();
- s.pop();
- }
- cout << endl << endl;
- k.clear();
- q.pop();
- }
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Latest pastes
8 hours ago
1 days ago
3 days ago
3 days ago
3 days ago