SHARE
TWEET

lab8zad1

a guest Jan 15th, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.     int tab[5],tab2[5];
  7.     int k,j=0,x=0;
  8.     for(int i=0;i<5;i++){
  9.         do{
  10.             printf("Podaj %d element tablicy: ", i);
  11.             k=scanf("%d", &tab[i]);
  12.             if(k==0) printf("blad formatu");
  13.             fflush(stdin);
  14.         }while(k==0);
  15.     }
  16.    
  17.     for(int i=0; i<5; i++) {
  18.         if(tab[i]%2 == 0){
  19.             tab2[j] = tab[i];
  20.             j++;
  21.         }
  22.         else{
  23.             tab2[4-x] = tab[i];
  24.             x++;
  25.         }
  26.        
  27.     }
  28.     printf("\n przed: ");
  29.     for(int i=0; i<5; i++){
  30.         printf("%d", tab[i]);
  31.     }
  32.     printf("\n po: ");
  33.     for(int i=0; i<5; i++){
  34.         printf("%d", tab2[i]);
  35.     }
  36.     return 0;
  37.    
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top