Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4. #define printStart printf("Please enter the width of your square, the max num of chars per line, and the max num of lines:\n");
  5. #define printTchau printf("Good Bye!\n");
  6. #define printMinus printf("-");
  7. #define printPlus printf("+");
  8. #define printSpecialFrame printf("@");
  9. #define printNormalFrame printf("#");
  10. #define printNewLine printf("\n");
  11.  
  12. int main (){
  13.  
  14. int width;
  15. int MaxChars;
  16. int MaxLines;
  17. int I=0,J,K; // counters
  18. int WholeSquare;
  19. int LeftOver;
  20. int row;
  21. int column=0;
  22.  
  23. printStart;
  24. scanf("%d%d", &width, &MaxChars);
  25.  
  26. WholeSquare=MaxChars/width;
  27. LeftOver=MaxChars%width;
  28.  
  29. for (row=0; row<width; row++) // max lines of square
  30. {
  31.     while (I<MaxChars)  // max chars in line
  32.     {
  33.         for (J=0; J<=WholeSquare; J++)  // J= number of whole squares
  34.         {
  35.             for (column=0; column<width; column++)
  36.             {
  37.                 if (column<(width-row)){
  38.                     printNormalFrame;
  39.                     I++;
  40.                 }
  41.                 else {
  42.                     printMinus;
  43.                     I++;
  44.                 }
  45.             }
  46.            
  47.         }
  48.         column=0;
  49.         for (K=0;K<=LeftOver;K++)
  50.         {
  51.             if (column<(width-row))
  52.             {
  53.                 printPlus;
  54.                 I++;
  55.             }
  56.             else
  57.             {
  58.                 printMinus;
  59.                 I++;
  60.             }
  61.             column++;
  62.         }
  63.        
  64.     }
  65.     I=0;
  66.     printNewLine;
  67.  
  68.  
  69. }
  70.  
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement