fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class uzel
  6. {
  7. private:
  8. int dannye;
  9. uzel* u_sled;
  10. uzel* u_pred;
  11. public:
  12. friend class spisok;
  13. };
  14.  
  15. class spisok
  16. {
  17. private:
  18. uzel* u_golova;
  19. uzel* u_hvost;
  20. public:
  21. spisok(): u_golova(NULL), u_hvost(NULL) {}
  22. //Создаём новый узел списка
  23. void push(int znach)
  24. {
  25. uzel* u_NovUzel = new uzel;
  26. u_NovUzel->dannye = znach;
  27. if (u_golova != NULL)
  28. {
  29. u_golova->u_pred = u_NovUzel;
  30. }
  31. u_NovUzel->u_pred = NULL;
  32. u_NovUzel->u_sled = u_golova;
  33. if (u_NovUzel->u_sled == NULL) u_hvost = u_NovUzel;
  34. u_golova = u_NovUzel;
  35. }
  36. //Вывод списка начиная с головы
  37. void sled()
  38. {
  39. uzel* u_SledUzel = u_golova;
  40. while (u_SledUzel)
  41. {
  42. cout << u_SledUzel->dannye << endl;
  43. u_SledUzel = u_SledUzel->u_sled;
  44. }
  45. }
  46. //Вывод списка начиная с хвоста
  47. void pred()
  48. {
  49. uzel* u_PredUzel = u_hvost;
  50. while (u_PredUzel)
  51. {
  52. cout << u_PredUzel->dannye << endl;
  53. u_PredUzel = u_PredUzel->u_pred;
  54. }
  55. }
  56. };
  57.  
  58. int main()
  59. {
  60. spisok stek;
  61. string vvod = "&";
  62. while (vvod != "exit")
  63. {
  64. int znach;
  65. cin >> vvod;
  66. if (vvod == "push") { cin >> znach; stek.push(znach); }
  67. if (vvod == "sled") stek.sled();
  68. if (vvod == "pred") stek.pred();
  69. }
  70.  
  71. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty