#include <iostream> #include <string> using namespace std; class uzel { private: int dannye; uzel* u_sled; uzel* u_pred; public: friend class spisok; }; class spisok { private: uzel* u_golova; uzel* u_hvost; public: spisok(): u_golova(NULL), u_hvost(NULL) {} //Создаём новый узел списка void push(int znach) { uzel* u_NovUzel = new uzel; u_NovUzel->dannye = znach; if (u_golova != NULL) { u_golova->u_pred = u_NovUzel; } u_NovUzel->u_pred = NULL; u_NovUzel->u_sled = u_golova; if (u_NovUzel->u_sled == NULL) u_hvost = u_NovUzel; u_golova = u_NovUzel; } //Вывод списка начиная с головы void sled() { uzel* u_SledUzel = u_golova; while (u_SledUzel) { cout << u_SledUzel->dannye << endl; u_SledUzel = u_SledUzel->u_sled; } } //Вывод списка начиная с хвоста void pred() { uzel* u_PredUzel = u_hvost; while (u_PredUzel) { cout << u_PredUzel->dannye << endl; u_PredUzel = u_PredUzel->u_pred; } } }; int main() { spisok stek; string vvod = "&"; while (vvod != "exit") { int znach; cin >> vvod; if (vvod == "push") { cin >> znach; stek.push(znach); } if (vvod == "sled") stek.sled(); if (vvod == "pred") stek.pred(); } }
Standard input is empty
Main.java:1: error: illegal character: '#' #include <iostream> ^ Main.java:1: error: class, interface, or enum expected #include <iostream> ^ Main.java:2: error: illegal character: '#' #include <string> ^ Main.java:7: error: illegal start of type private: ^ Main.java:9: error: <identifier> expected uzel* u_sled; ^ Main.java:9: error: <identifier> expected uzel* u_sled; ^ Main.java:10: error: <identifier> expected uzel* u_pred; ^ Main.java:10: error: <identifier> expected uzel* u_pred; ^ Main.java:11: error: illegal start of type public: ^ Main.java:12: error: <identifier> expected friend class spisok; ^ Main.java:12: error: '{' expected friend class spisok; ^ Main.java:17: error: illegal start of type private: ^ Main.java:18: error: <identifier> expected uzel* u_golova; ^ Main.java:18: error: <identifier> expected uzel* u_golova; ^ Main.java:19: error: <identifier> expected uzel* u_hvost; ^ Main.java:19: error: <identifier> expected uzel* u_hvost; ^ Main.java:20: error: illegal start of type public: ^ Main.java:21: error: ';' expected spisok(): u_golova(NULL), u_hvost(NULL) {} ^ Main.java:25: error: '(' or '[' expected uzel* u_NovUzel = new uzel; ^ Main.java:26: error: not a statement u_NovUzel->dannye = znach; ^ Main.java:29: error: not a statement u_golova->u_pred = u_NovUzel; ^ Main.java:31: error: not a statement u_NovUzel->u_pred = NULL; ^ Main.java:32: error: not a statement u_NovUzel->u_sled = u_golova; ^ Main.java:42: error: not a statement cout << u_SledUzel->dannye << endl; ^ Main.java:52: error: not a statement cout << u_PredUzel->dannye << endl; ^ Main.java:65: error: not a statement cin >> vvod; ^ Main.java:66: error: not a statement if (vvod == "push") { cin >> znach; stek.push(znach); } ^ Main.java:71: error: reached end of file while parsing } ^ 28 errors
Standard output is empty