4:57 PM Drawing Square, Triangle, Diagonal |
برنامج لرسم الأشكال الهندسية #include"stdio.h" main() { int i, j, k, s; printf("\nChoose the shape ( 1,2-Square, 3,4-Triangle, 5,6,7,8-Diagonal ) = "); scanf("%d", &s); printf("\n\n"); if(s == 1){ for(i=0;i<=10;i++){ for(j=0;j<=10;j++){ printf(" * "); } printf("\n"); } } else if(s == 2){ for(i=0;i<=10;i++){ printf(" * "); } printf("\n"); for(j=0;j<=10;j++){ printf(" * *"); printf("\n"); } for(i=0;i<=10;i++){ printf(" * "); } printf("\n"); } else if(s == 3){ for(i=0;i<=10;i++){ for(j=0;j<=i;j++){ printf(" * "); } printf("\n"); } } else if(s == 4){ for(i=0;i<=10;i++){ for(j=i;j<=10;j++){ printf(" * "); } printf("\n"); } } else if(s == 5){ for(i=0;i<=10;i++){ for(j=0;j<=10;j++){ if(i == j){ printf(" * "); } else{ printf(" "); } } printf("\n"); } } else if(s == 6){ for(i=0;i<=10;i++){ for(j=0;j<=10;j++){ if(i == (10-j)){ printf(" * "); } else{ printf(" "); } } printf("\n"); } } else if(s == 7){ for(i=0;i<=10;i++){ for(j=0;j<=10;j++){ if(i == (10-j) || i == j){ printf(" * "); } else{ printf(" "); } } printf("\n"); } } else if(s == 8){ for(i=0;i<=10;i++){ for(j=0;j<=10;j++){ if(i == (5-j) || i == (j-5) || j == (i-5)){ printf(" * "); } else{ printf(" "); } } printf("\n"); } } return main(); getch(); } |
|
Total comments: 0 | |