Created
June 11, 2018 08:50
-
-
Save OwiseKyawMinOo/626ece2562b89c618c2932758f23143f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
#include<stdlib.h> | |
#include<process.h> | |
#include<time.h> | |
int diamond(int x, int y, char ch); | |
void delay(unsigned int mseconds); | |
int diamondflash(); | |
int rectangle(int x,int y,int d,char ch); | |
int triangle1(int y); | |
int triangle2(int x, int y); | |
int triangle3(int y); | |
int triangle4(int y); | |
int main() | |
{ | |
for (int j = 5; j<80; j++) | |
{ | |
diamond(j, 5, '**'); | |
delay(50); | |
system("cls"); | |
//system("COLOR 1F"); | |
} | |
diamondflash(); | |
for (int u = 0; u < 37; u++) | |
{ | |
if (u < 3) | |
{ | |
triangle1(u); | |
delay(200); | |
system("COLOR 0B"); | |
} | |
else if (u < 6) | |
{ | |
triangle2(u, u); | |
delay(200); | |
system("COLOR 0C"); | |
} | |
else if (u <9) | |
{ | |
triangle3(u); | |
delay(200); | |
system("COLOR 0D"); | |
} | |
else if (u <12) | |
{ | |
triangle4(u); | |
delay(200); | |
system("COLOR 0E"); | |
} | |
else if (u <15) | |
{ | |
triangle1(u); | |
delay(200); | |
system("COLOR 0B"); | |
} | |
else if (u <18) | |
{ | |
triangle2(u, u); | |
delay(200); | |
system("COLOR 0C"); | |
} | |
else if (u <21) | |
{ | |
triangle3(u); | |
delay(200); | |
system("COLOR 0D"); | |
} | |
else if (u <24) | |
{ | |
triangle4(u); | |
delay(200); | |
system("COLOR 0E"); | |
} | |
else if (u <27) | |
{ | |
triangle1(u); | |
delay(200); | |
system("COLOR 0B"); | |
} | |
else if (u <30) | |
{ | |
triangle2(u, u); | |
delay(200); | |
system("COLOR 0C"); | |
} | |
else if (u <33) | |
{ | |
triangle3(u); | |
delay(200); | |
system("COLOR 0D"); | |
} | |
else if (u <36) | |
{ | |
triangle4(u); | |
delay(200); | |
system("COLOR 0E"); | |
} | |
} | |
for(int i=5,j=5;i<=35,j<=35;i++,j++) | |
{ | |
rectangle(i,j,10,'*'); | |
delay(100); | |
system("cls"); | |
} | |
return 0; | |
} | |
int diamondflash() | |
{ | |
for (int i = 0; i <= 20; i++) | |
{ | |
for (int j = 0; j <= 20 - i; j++) | |
{ | |
printf(" "); | |
} | |
for (int k = 0; k <= i; k++) | |
printf("**"); | |
printf("\n"); | |
delay(100); | |
} | |
for (int i = 20; i >= 0; i--) | |
{ | |
for (int j = 20 - i; j >= 0; j--) | |
{ | |
printf(" "); | |
} | |
for (int k = i; k >= 0; k--) | |
printf("**"); | |
printf("\n"); | |
delay(100); | |
} | |
delay(1000); | |
return 0; | |
} | |
int diamond(int x, int y, char ch) | |
{ | |
for (int i = 0; i <= y; i++) | |
{ | |
for (int j = 0; j <= x - i; j++) | |
{ | |
printf(" "); | |
} | |
for (int k = 0; k <= i; k++) | |
printf("%c%c", ch, ch); | |
printf("\n"); | |
} | |
for (int i = y; i >= 0; i--) | |
{ | |
for (int j = x - i; j >= 0; j--) | |
{ | |
printf(" "); | |
} | |
for (int k = i; k >= 0; k--) | |
printf("%c%c", ch, ch); | |
printf("\n"); | |
} | |
return 0; | |
} | |
int rectangle(int x,int y,int d,char ch) | |
{ | |
int r=d/2; | |
system("cls"); | |
for(int k=1;k<=y-r-1;k++) | |
{ | |
printf("\n"); | |
} | |
for(int j=y-r;j<=y+r;j++) | |
{ | |
for(int i=1;i<=x-r-1;i++) | |
{ | |
printf(" ",ch); | |
} | |
for(int i=x-r;i<=x-r;i++) | |
{ | |
printf("%c",ch); | |
} | |
for(int i=x-r+1;i<=x+r-1-1;i++) | |
{ | |
if((j==y-r)||(j==y+r)) | |
{ | |
printf("%c",ch); | |
} | |
else | |
{ | |
printf(" "); | |
} | |
} | |
for(int i=x+r;i<=x+r;i++) | |
{ | |
printf("%c",ch); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} | |
int triangle1(int y) | |
{ | |
system("cls"); | |
for (int i = 0; i<y; i++) | |
{ | |
printf("\n"); | |
} | |
for (int i = 0; i<11; i++) | |
{ | |
for (int j = 0; j<11 - i; j++) | |
{ | |
printf(" "); | |
} | |
for (int j = 0; j<i; j++) | |
printf("*"); | |
printf("\n"); | |
} | |
return 0; | |
} | |
int triangle2(int x, int y) | |
{ | |
system("cls"); | |
for (int i = 0; i<y; i++) | |
{ | |
printf(" \n"); | |
} | |
for (int i = 0; i<11; i++) | |
{ | |
for (int j = 0; j<i; j++) | |
{ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} | |
int triangle3(int y) | |
{ | |
system("cls"); | |
for (int i = 0; i<y; i++) | |
{ | |
printf(" \n"); | |
} | |
for (int i = 0; i<11; i++) | |
{ | |
for (int j = 0; j<11 - i; j++) | |
{ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} | |
int triangle4(int y) | |
{ | |
system("cls"); | |
for (int i = 0; i<y; i++) | |
{ | |
printf(" \n"); | |
} | |
for (int i = 0; i<11; i++) | |
{ | |
for (int j = 0; j<i; j++) | |
{ | |
printf(" "); | |
} | |
for (int j = 0; j<11 - i; j++) | |
printf("*"); | |
printf("\n"); | |
} | |
return 0; | |
} | |
void delay(unsigned int mseconds) | |
{ | |
clock_t goal = mseconds + clock(); | |
while (goal>clock()) | |
{ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment