Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to draw a rectangle with diagonals and axes of symmetry in c ++ in the console?

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#include <math.h>


int main(int argc, char *argv[]) {
int s,d;
    printf ("the length of the rectangle 
");
    scanf ("%d",&s);
    printf ("width of the rectangle 
 ");
    scanf ("%d",&d);
    int l;
    int p;
    int przekatna; 

    for (p=1; p<=s; p++)
    {
    printf ("
");
    for (l=1;l<=d; l++)
    {

    if(p==1 || l==1 || l==d || s==p || p==((d+1)/2)  ) printf("*"); else printf(" ");
    if ( l==(d)/2 && p!=((d+1)/2) && p!=1 && p!=s) 
    printf("*"); else printf(""); 


    }
}
     return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #draw #rectangle #diagonals #axes #symmetry
ADD COMMENT
Topic
Name
2+2 =