daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define f cin
  6. #define g cout
  7.  
  8. struct nod
  9. {
  10.     char inf;
  11.     int leg;
  12.  
  13. } v[101];
  14.  
  15. int main()
  16. {
  17.     int n, k, p, i, t;
  18.     f >> n >> k >> p;
  19.     t = k;
  20.  
  21.     for(i = 1; i <= n; i++)
  22.     {
  23.         v[i].inf = 'a' + i - 1;
  24.         v[i].leg = i + 1;
  25.     }
  26.  
  27.     v[n].leg = 1;
  28.  
  29.     while(v[t].leg != t)
  30.     {
  31.         for(i  = 1; i <= p - 1; i++)
  32.             t = v[t].leg;
  33.         g << v[v[t].leg].inf << ' ';
  34.         v[t].leg = v[v[t].leg].leg;
  35.     }
  36.     g << '\n';
  37.     g << v[t].inf;
  38.  
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top