Advertisement
J00ker

Untitled

Jun 2nd, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. struct Nod
  8. {
  9.     int info;
  10.     Nod *leg;
  11. };
  12.  
  13. Nod *L;
  14.  
  15. int main()
  16. {
  17.     srand(time(0));
  18.  
  19.     Nod *p;
  20.     L =  new Nod;
  21.     L -> info = 1;
  22.     L -> leg = L;
  23.  
  24.     /*
  25.     p = new Nod;
  26.     p -> info = rand() % 99 + 1;
  27.     p -> leg = L -> leg;
  28.     L -> leg = p;
  29.     */
  30.  
  31.     int n = rand() % 20 + 1; cout << n << ": ";
  32.  
  33.     for(int i = 2; i <= n; i++)
  34.     {
  35.         p = new Nod;
  36.         p -> info = i;
  37.         p -> leg = L -> leg;
  38.         L -> leg = p;
  39.         L = p;
  40.     }
  41.     for(p = L -> leg; p != L; p = p -> leg)
  42.         cout << p -> info << " ";
  43.     cout << p -> info << "\n";
  44.  
  45.     int x, f = 0;
  46.     cout << "x:"; cin >> x;
  47.     for(p = L -> leg; p != L; p = p -> leg)
  48.         if(p -> info == x)
  49.         {
  50.             f = 1;
  51.             break;
  52.         }
  53.     if(p -> info == x)
  54.         f = 1;
  55.  
  56.     if(f)
  57.         cout << "ARAPE!?!?!?\n";
  58.     else
  59.         cout << "nu ARAPE!?!?!?\n";
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement