Advertisement
Guest User

działa póki nie podamy 3 liczb pod rzad np 1 2 3

a guest
Jan 22nd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. int main(int argc, char** argv)
  6. {
  7. int x,i,max=0,licznik=0,tab[100];
  8. printf("podaj liczby:");
  9.  
  10.  
  11. for (int i = 0; i < 100; i++)
  12. {
  13.     scanf("%d",&x);
  14.     tab[i]=x;
  15.     licznik=licznik+1;
  16.  
  17. if (max<x)
  18. {
  19.     max = x;
  20. }
  21.  
  22. if (i > 1)
  23. {
  24.     if (tab[i]-1 == tab[i-1] && tab[i-1]-1 == tab[i-2])
  25.     {
  26.         break;
  27.     }
  28.    
  29. }
  30. }
  31. printf("Podanych liczb było %d a najwiekszy element to %d ", licznik, max );
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement