Advertisement
xathrya

Pattern Me

Nov 20th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. /* Compile it using: g++ pola.cpp -o pola */
  2. /* Why use stdio? It's cheap and enough for this kind of work */
  3.  
  4. #include <cstdio>
  5. using namespace std;
  6.  
  7. int main() {
  8.     int N, i, j;
  9.    
  10.     printf("Nilai N : ");
  11.     scanf("%d", &N);
  12.    
  13.     for (i=0; i<N; i++) {
  14.         if (i%3==0) {
  15.             for (j=0; j<=i; j++){
  16.                 if (j==0 || j==i) {
  17.                     printf("#");
  18.                 } else {
  19.                     printf("%d", j%10);
  20.                 }
  21.             }
  22.         } else {
  23.             for (j=0; j<=i; j++){
  24.                 if (j==0 || j==i) {
  25.                     printf("#");
  26.                 } else {
  27.                     printf(" ");
  28.                 }
  29.             }
  30.         }
  31.         printf("\n");
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement