Advertisement
erfanul007

Untitled

Jan 12th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int> pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define pb push_back
  14. #define pob pop_back
  15. #define mp make_pair
  16. #define ff first
  17. #define ss second
  18. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  19. #define loop(i,y) for(int i=0; i<int(y); i++)
  20. #define rloop(i,y) for(int i=int(y); i>0; i--)
  21. #define rloop1(i,y) for(int i=int(y)-1; i>=0; i--)
  22. #define read() freopen("input.txt", "r", stdin)
  23. #define write() freopen("output.txt", "w", stdout)
  24. #define cspf(i) printf("Case %d: ", i)
  25. #define all(v) v.begin(),v.end()
  26. /// Constants
  27. #define eps 1e-9
  28. #define PI acos(-1.0) // 3.1415926535897932
  29.  
  30. int main()
  31. {
  32. char s[100],st[100];
  33. scanf("%s",s);
  34. int ln=strlen(s);
  35. int x;
  36. if(ln<=2){
  37. printf("%s\n",s);
  38. return 0;
  39. }
  40. x=ln/2;
  41. if(ln%2==0)
  42. x--;
  43. int i=0;
  44. int prev=x-1;
  45. int next=x+1;
  46. st[i]=s[x];
  47. i++;
  48. while(i<ln){
  49. if(i%2==1){
  50. st[i]=s[next];
  51. next++;
  52. i++;
  53. continue;
  54. }
  55. if(i%2==0){
  56. st[i]=s[prev];
  57. prev--;
  58. i++;
  59. continue;
  60. }
  61. }
  62. st[i]='\0';
  63. printf("%s\n",st);
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement