Advertisement
MikecIT

Vezba 1 // Zadatak 5

Sep 4th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int i=1,k,xu,yu,par,nep,brp=0,brn=0,n,cif,pret,br=0;
  7. printf("Unesite k=");
  8. xu=wherex();
  9. yu=wherey();
  10. do{
  11. gotoxy(xu,yu);
  12. printf("           ");
  13. gotoxy(xu,yu);
  14. scanf("%d",&k);
  15. }while(k<=1);
  16. do{
  17. printf("\n(%d) Unesite prirodan broj n : ",i);
  18. xu=wherex();
  19. yu=wherey();
  20. do{
  21. gotoxy(xu,yu);
  22. printf("    ");
  23. gotoxy(xu,yu);
  24. n=0;
  25. do{
  26. do{
  27. cif=getch();
  28. }while(((cif<'0'||cif>'9')||(n==0&&cif=='0'))&&cif!=13);
  29. if(cif!=13){
  30. n=n*10+cif-48;
  31. printf("%c",cif);
  32. }
  33. }while(cif!=13);
  34. }while(n<1);
  35. if(i==1)nep=n,brp=1,pret=n,br=0;
  36. if(i==2)par=n,brn=1;
  37. if(i>2)
  38.     {
  39.     if(i%2==0)
  40.         {
  41.         if(n==par)brp++;
  42.         else par=n,brp=1;
  43.         }
  44.     else
  45.         {
  46.         if(n==nep)brn++;
  47.         else nep=n,brn=1;
  48.         }
  49.     }
  50. if(i>1&&n>pret)br++;
  51. pret=n;
  52. i++;
  53. }while(brp!=k&&brn!=k);
  54. printf("\n\n%d brojeva ima vrednost vecu od vrednosti svog prethodnika.",br);
  55. getch();
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement