Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define N 3
- #define M 3
- double z2(int a, int b, double n)
- {
- int odp=0; int x=0; int y=0;
- double zliczam=0;
- srand (time(NULL));
- for(int i=0;i<n;i++)
- {
- x=(rand()%(b-a))+a;
- y=(rand()%(b-a))+a;
- printf("%d * %d=", x, y);
- scanf("%d", &odp);
- if(odp==(x*y))
- {
- zliczam++;
- }
- }
- return ((zliczam/n)*100);
- }
- void z3()
- {
- int i;
- int j;
- int tab[N][M];
- int max=0;
- int kolumna=0;
- for ( i=0;i<N;i++)
- {
- for( j=0;j<M;j++)
- {
- printf("Podaj liczbe: ");
- scanf("%d", &tab[i][j]);
- if(tab[i][j]>9 || tab[i][j]<0)
- {
- printf("Podaj prawidlowa liczbe: ");
- scanf("%d", &tab[i][j]);
- }
- }
- }
- for( i =0;i<N;i++)
- {
- for ( j=0;j<M;j++)
- {
- printf ("%d ", tab[i][j]);
- }
- printf("\n");
- }
- for( j =0;i<M;j++)
- {
- int podzielne=0;
- for ( i=0;i<N;i++)
- {
- if(tab[i][j]%3==0)
- {
- podzielne=podzielne+1;
- }
- }
- if(podzielne>max)
- {
- max=podzielne;
- kolumna=j+1;
- }
- }
- printf("Kolumna z najwieksza iloscia liczb podzielnych przez 3 jest kolumna: %d", kolumna);
- }
- int main()
- {
- int a,b,n;
- printf("Podaj przedział dolny: ");
- scanf("%d", &a);
- printf("Podaj przedział gorny: ");
- scanf("%d", &b);
- printf("Podaj ilosc prob: ");
- scanf("%d", &n);
- printf ("%6.2f", z2(a, b ,n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement