0% found this document useful (0 votes)
19 views

Shape (Code C Basic)

Uploaded by

tungnthe153407
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Shape (Code C Basic)

Uploaded by

tungnthe153407
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdio.

h>
#include<math.h>

int main () {
printf("Nhap chieu cao tam giac can :");
int h;
scanf("%d",&h);

int i,j;
for ( i = 0 ; i <= h ; i++) {
for ( j = 0 ; j < h-i ; j++ ) {
printf(" ");
}
for ( j = 0 ; j < 2*i - 1 ; j++) {
printf("*");
}
printf("\n");
}

printf("\n");
printf("Nhap do dai hinh vuong :");
int a;
scanf("%d", &a);

for ( i = 0 ; i < a ; i++) {


for ( j = 0 ; j < a ; j++) {
printf("* ");
}
printf("\n");
}

printf ("\n");
printf("Nhap do dai hinh vuong rong :");
int b;
scanf("%d", &b);

for ( i = 0 ; i < b ; i++) {


for ( j = 0 ; j < b ; j++) {
if ( i == 0 || i == b - 1 || j == 0 || j == b - 1) {
printf("* ");
} else {
printf(" ");
}
}
printf("\n");
}

printf("\n");
printf("Nhap chieu cao tam giac nguoc :");
int heigh;
scanf("%d", &heigh);

for ( i = 0 ; i < heigh ; i++) {


for ( j = 0 ; j < i ; j++) {
printf(" ");
}
for ( j = 0 ; j < heigh - i ; j++) {
printf("* ");
}
printf("\n");
}

printf("\n");
printf("Nhap chieu cao tam giac vuong nguoc :");
int d;
scanf("%d", &d);

for ( i = d ; i >= 0 ; i--) {


for ( j = 0 ; j < d - i ; j++) {
printf(" ");
}
for ( j = 0 ; j <= i ; j++) {
printf("*");
}
printf("\n");
}
return 0;
}

You might also like