Advertisement
elektryk798

Kartowka_C_2

Jan 26th, 2017
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int realok(int *r);
  5. void czytajtab(int *tab,int n);
  6.  
  7. int main()
  8. {
  9.     int *t=NULL,rozmiar=0;
  10.     t=realok(&rozmiar);
  11.     czytajtab(t,rozmiar);
  12.     return 0;
  13. }
  14.  
  15. int realok(int *r)
  16. {
  17.     int *tab=NULL;
  18.     int i=0,co;
  19.     for(;;)
  20.     {
  21.         scanf("%d",&co);
  22.         if (co==0) break;
  23.         tab=(int*)realloc(tab,(i+1)*sizeof(int));
  24.         *(tab+i)=co;
  25.         i++;
  26.     }
  27.     *r=i;
  28.     return tab;
  29. }
  30. void czytajtab(int *tab,int n)
  31. {
  32.     int i=0;
  33.     printf("Zawartosc tablicy: ");
  34.     for(;i<n;i++)
  35.         printf("%d, ",*(tab+i));
  36. }
  37. /*
  38. int kartkowka(double *n, double *d, double *u, double *s)
  39. { int *t=NULL,a,i=0,sum=0,uj=0;
  40.     do
  41.     {   fflush(stdin);
  42.         scanf("%d",&a);
  43.         if(a==0)
  44.             break;
  45.         t=(double*)realloc(t,(i+1)*sizeof(double));
  46.         *(t+i)=a;
  47.         i++;
  48.             if(a<0)
  49.             { uj++;
  50.               sum+=a;
  51.             }
  52.     }
  53.     while(1);
  54.     *n=i;
  55.     *u=uj;
  56.     *d=i-uj;
  57.     *s=suma/uj;
  58.     return tab;
  59. }
  60. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement