Problem link:
490 - Rotating Sentences
Solution:
490 - Rotating Sentences
Solution:
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int S = 103;
- const int MOD = 1e9+7;
- const double pi = 2 * acos (0.0);
- int _I(){int x; scanf("%d", &x); return x;}
- LL _LL(){LL x; scanf("%lld", &x); return x;}
- int dirX[]={1, 0, -1, 0, 1, -1, 1, -1};
- int dirY[]={0, 1, 0, -1, 1, -1, -1, 1};
- int rX[] = {1, 1, 2, 2, -1, -1, -2, -2};
- int rY[] = {2, -2, 1, -1, 2, -2, 1, -1};
- template <class T> T Distance(T x1, T y1, T x2, T y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));};
- int sset(int N, int pos){return N=N|(1<<pos);}
- bool check(int N, int pos){return (bool)(N&(1<<pos));}
- int reset(int N, int pos){return N=N&~(1<<pos);}
- ///...............Code Starts From Here...............///
- char s[S][S];
- int main(){
- int k = 0, mx = 0;
- memset(s, ' ', sizeof(s));
- while(gets(s[k])){
- int sz = strlen(s[k]);
- s[k][sz] = 32;
- mx = max(mx, sz);
- k++;
- }
- for(int i = 0; i < mx; i++){
- for(int j = k-1; j >= 0; j--){
- printf("%c", s[j][i]);
- }
- puts("");
- }
- return 0;
- }
No comments:
Post a Comment