Thursday, September 1, 2016

UVa - 490 - Rotating Sentences

Problem link:
490 - Rotating Sentences

Solution:
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. const int S = 103;
  5. const int MOD = 1e9+7;
  6. const double pi = 2 * acos (0.0);
  7. int _I(){int x; scanf("%d"&x); return x;}
  8. LL _LL(){LL x; scanf("%lld"&x); return x;}
  9. int dirX[]={10-101-11-1};
  10. int dirY[]={010-11-1-11};
  11. int rX[] = {1122-1-1-2-2};
  12. int rY[] = {2-21-12-21-1};
  13.  
  14. template <class T> T Distance(T x1, T y1, T x2, T y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));};
  15.  
  16. int sset(int N, int pos){return N=N|(1<<pos);}
  17. bool check(int N, int pos){return (bool)(N&(1<<pos));}
  18. int reset(int N, int pos){return N=N&~(1<<pos);}
  19. ///...............Code Starts From Here...............///
  20.  
  21. char s[S][S];
  22.  
  23. int main(){
  24.     int k = 0, mx = 0;
  25.     memset(s, ' 'sizeof(s));
  26.     while(gets(s[k])){
  27.         int sz = strlen(s[k]);
  28.         s[k][sz] = 32;
  29.         mx = max(mx, sz);
  30.         k++;
  31.     }
  32.     for(int i = 0; i < mx; i++){
  33.         for(int j = k-1; j >= 0; j--){
  34.             printf("%c", s[j][i]);
  35.         }
  36.         puts("");
  37.     }
  38.     return 0;
  39. }

No comments:

Post a Comment