Advertisement
dzieciol

Labolatorium IV zadanie 3

Nov 23rd, 2015
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int d,i;
  7.     printf("podaj ilość elementów   \n");
  8.     scanf("%d",&d);
  9.  
  10.     float dod[20];
  11.     float nied[20];
  12.     float x;
  13.     int q=0,w=0;
  14.     for(i=0;i<d;i++){
  15.             printf("podaj element numer %d z %d  -",i+1,d);
  16.      scanf("%f",&x);
  17.      if(x>0) {dod[q]=x; q++;} else
  18.         {
  19.             nied[w]=x; w++;
  20.         }
  21. }
  22.  
  23.  
  24.  
  25. printf("tablica dodatnia \n");
  26. for (i=0;i<=q;i++){
  27.    printf("%f \n",dod[i]);
  28. }
  29. printf("tablica niedodatnia \n");
  30. for(i=0;i<=w;i++){
  31.   printf("%f \n",nied[i]);
  32. }
  33. x=0;
  34. for (i=0;i<q;i++)
  35.     x=x+dod[i];
  36.     for (i=0;i<w;i++)
  37.         x=x+nied[i];
  38. printf("%f",x);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement