Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- struct Nod
- {
- int info;
- Nod *leg;
- };
- Nod *L;
- int main()
- {
- srand(time(0));
- Nod *p;
- L = new Nod;
- L -> info = 1;
- L -> leg = L;
- /*
- p = new Nod;
- p -> info = rand() % 99 + 1;
- p -> leg = L -> leg;
- L -> leg = p;
- */
- int n = rand() % 20 + 1; cout << n << ": ";
- for(int i = 2; i <= n; i++)
- {
- p = new Nod;
- p -> info = i;
- p -> leg = L -> leg;
- L -> leg = p;
- L = p;
- }
- for(p = L -> leg; p != L; p = p -> leg)
- cout << p -> info << " ";
- cout << p -> info << "\n";
- int x, f = 0;
- cout << "x:"; cin >> x;
- for(p = L -> leg; p != L; p = p -> leg)
- if(p -> info == x)
- {
- f = 1;
- break;
- }
- if(p -> info == x)
- f = 1;
- if(f)
- cout << "ARAPE!?!?!?\n";
- else
- cout << "nu ARAPE!?!?!?\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement