Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- void kwadrat(int t[],int count);
- void printtab(int t[],int a,int b);
- void reszta(int t[],int count);
- int avg(int t[],int b);
- int main()
- {
- int tablica[3][3]={{1,2,3},
- {11,10,22},
- {23,90,10}};
- int rows=sizeof(tablica)/sizeof(tablica[0]);
- int cols=sizeof(tablica[0])/sizeof(int);
- printtab(tablica,rows,cols);
- kwadrat(tablica,rows*cols);
- printf("\n");
- printtab(tablica,rows,cols);
- reszta(tablica,rows*cols);
- printf("\n");
- printtab(tablica,rows,cols);
- for(int i=0;i<rows;i++)
- {
- printf("Œrednia w wierszu %d wynosi: %d ",avg(&tablica[i][0],rows*cols));
- }
- return 0;
- }
- void kwadrat(int t[],int count)
- {
- for(int i=0;i<count;i++)
- {
- t[i]=pow(t[i],2);
- }
- }
- void printtab(int t[],int a, int b)
- {
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<b;j++)
- {
- printf("%d ",t[j+i*a]);
- }
- printf("\n");
- }
- }
- void reszta(int t[],int count)
- {
- for(int i=0;i<count;i++)
- {
- t[i]=t[i]%2;
- }
- }
- int avg(int t[],int b)
- {
- int suma=t[0];
- int srednia=0;
- for(int i=1;i<b;i++)
- {
- suma=suma+t[i];
- }
- return suma/b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement