Advertisement
Guest User

Untitled

a guest
May 24th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int n,temp;
  7.     printf("podaj ilosc liczb: ");
  8.     scanf("%d",&n);
  9.     if(n<=0)
  10.     {
  11.         printf("liczba musi byc dodatnia");
  12.     }
  13.     else
  14.     {
  15.         int i, tab[n];
  16.         for(i=0;i<n;i++)
  17.         {
  18.             printf("podaj liczbe: ");
  19.             scanf("%d",&tab[i]);
  20.         }
  21.  
  22.         for(i=0;i<n-1;i++)
  23.         {
  24.             if(tab[i]>tab[i+1])
  25.             {
  26.                 temp = tab[i];
  27.                 tab[i] = tab[i+1];
  28.                 tab[i+1]=temp;
  29.             }
  30.  
  31.         }
  32.             printf("Druga najwieksza liczba to %d", tab[i-1]);
  33.     }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement