Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- struct item {
- char s[100];
- item * next;
- } * first, * last;
- char s[100];
- int n;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- fin >> n;
- fin.getline(s, 100);
- first = last = NULL;
- while (n--) {
- fin.getline(s, 100);
- item * cur = new item;
- cur -> next = NULL;
- strcpy(cur -> s, s);
- fout << s << endl;
- if (first == NULL)
- first = last = cur;
- else {
- cur -> next = first;
- first = cur;
- }
- }
- fout << endl;
- for (item * cur = first; cur; cur = cur -> next)
- fout << cur -> s << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment