Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define printStart printf("Please enter the width of your square, the max num of chars per line, and the max num of lines:\n");
- #define printTchau printf("Good Bye!\n");
- #define printMinus printf("-");
- #define printPlus printf("+");
- #define printSpecialFrame printf("@");
- #define printNormalFrame printf("#");
- #define printNewLine printf("\n");
- int main (){
- int width;
- int MaxChars;
- int MaxLines;
- int I=0,J,K; // counters
- int WholeSquare;
- int LeftOver;
- int row;
- int column=0;
- printStart;
- scanf("%d%d", &width, &MaxChars);
- WholeSquare=MaxChars/width;
- LeftOver=MaxChars%width;
- for (row=0; row<width; row++) // max lines of square
- {
- while (I<MaxChars) // max chars in line
- {
- for (J=0; J<=WholeSquare; J++) // J= number of whole squares
- {
- for (column=0; column<width; column++)
- {
- if (column<(width-row)){
- printNormalFrame;
- I++;
- }
- else {
- printMinus;
- I++;
- }
- }
- }
- column=0;
- for (K=0;K<=LeftOver;K++)
- {
- if (column<(width-row))
- {
- printPlus;
- I++;
- }
- else
- {
- printMinus;
- I++;
- }
- column++;
- }
- }
- I=0;
- printNewLine;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement