Advertisement
Guest User

Referência para TOANDFRO (Luiza)

a guest
Feb 27th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char dec[210][25];
  4. char mess[210];
  5. int n;
  6.  
  7. int main() {
  8.     while (1) {
  9.         scanf("%d", &n);
  10.         if (!n) break;
  11.  
  12.         scanf(" %s", mess);
  13.         int line=0; int cnt=0;     
  14.  
  15.         for (int j=0; mess[j]!='\0'; j++) {
  16.             if (line%2) dec[line][n-j%n-1]=mess[j];
  17.             else dec[line][j%n]=mess[j];
  18.             cnt++;
  19.  
  20.             if (cnt==n) cnt=0, line++;
  21.         }
  22.  
  23.         for (int j=0; j<n; j++)
  24.             for (int i=0; i<line; i++)
  25.                 printf("%c", dec[i][j]);
  26.         printf("\n");
  27.     }
  28.  
  29.     return 0;  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement