Advertisement
MikecIT

6-3

Jun 19th, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <Windows.h>
  4.  
  5. int main()
  6. {
  7. int n,xu,yu,cif,i,j,k;
  8. printf("Unesite prirodan broj N: ");
  9. xu=wherex();
  10. yu=wherey();
  11. do{
  12. gotoxy(xu,yu);
  13. printf("    ");
  14. gotoxy(xu,yu);
  15. n=0;
  16. do{
  17. do{
  18. cif=getch();
  19. }while(((cif<'0'||cif>'9')||(n==0&&cif=='0'))&&cif!=13);
  20. if(cif!=13){
  21. n=n*10+cif-48;
  22. printf("%c",cif);
  23. }
  24. }while(cif!=13);
  25. }while(n<5||n>25||n%2==0);
  26. i=1;
  27. for(i=1;i<=40-n/2;i++){
  28.     clrscr();
  29.     gotoxy(i,13+n/2);
  30.     for(j=1;j<=n;j++)printf("*");
  31.     xu=wherex()-1;
  32.     yu=wherey();
  33.     for(j=1;j<=n/2;j++){
  34.         yu--;
  35.         xu--;
  36.         gotoxy(xu,yu);
  37.         printf("*");
  38.     }
  39.     for(j=1;j<=n/2;j++){
  40.         xu--;
  41.         yu++;
  42.         gotoxy(xu,yu);
  43.         printf("*");
  44.     }
  45.     gotoxy(81-n-i,13-n/2);
  46.     for(j=1;j<=n;j++)printf("*");
  47.     xu=wherex()-1;
  48.     yu=wherey();
  49.  
  50.     for(j=1;j<=n/2;j++){
  51.         yu++;
  52.         xu--;
  53.         gotoxy(xu,yu);
  54.         printf("*");
  55.     }
  56.     for(j=1;j<=n/2;j++){
  57.         yu--;
  58.         xu--;
  59.         gotoxy(xu,yu);
  60.         printf("*");
  61.     }
  62.     Sleep(50);
  63. }
  64.  
  65.     gotoxy(40-n/2+2,13-n/2+1);
  66.     xu=wherex();
  67.     yu=wherey();
  68.  
  69. gotoxy(1,22);
  70. getch();
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement