Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define N 3
  5. #define M 3
  6.  
  7.  
  8.  
  9.  
  10. double z2(int a, int b, double n)
  11. {
  12. int odp=0; int x=0; int y=0;
  13. double zliczam=0;
  14. srand (time(NULL));
  15.  
  16.  
  17. for(int i=0;i<n;i++)
  18. {
  19. x=(rand()%(b-a))+a;
  20. y=(rand()%(b-a))+a;
  21. printf("%d * %d=", x, y);
  22. scanf("%d", &odp);
  23. if(odp==(x*y))
  24. {
  25. zliczam++;
  26. }
  27. }
  28.  
  29. return ((zliczam/n)*100);
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. void z3()
  40. {
  41. int i;
  42. int j;
  43. int tab[N][M];
  44. int max=0;
  45. int kolumna=0;
  46. for ( i=0;i<N;i++)
  47. {
  48. for( j=0;j<M;j++)
  49. {
  50. printf("Podaj liczbe: ");
  51. scanf("%d", &tab[i][j]);
  52. if(tab[i][j]>9 || tab[i][j]<0)
  53. {
  54. printf("Podaj prawidlowa liczbe: ");
  55. scanf("%d", &tab[i][j]);
  56. }
  57.  
  58. }
  59. }
  60. for( i =0;i<N;i++)
  61. {
  62. for ( j=0;j<M;j++)
  63. {
  64. printf ("%d ", tab[i][j]);
  65. }
  66. printf("\n");
  67. }
  68.  
  69. for( j =0;i<M;j++)
  70. {
  71. int podzielne=0;
  72.  
  73. for ( i=0;i<N;i++)
  74. {
  75.  
  76. if(tab[i][j]%3==0)
  77. {
  78. podzielne=podzielne+1;
  79. }
  80. }
  81. if(podzielne>max)
  82. {
  83. max=podzielne;
  84. kolumna=j+1;
  85. }
  86. }
  87.  
  88. printf("Kolumna z najwieksza iloscia liczb podzielnych przez 3 jest kolumna: %d", kolumna);
  89.  
  90. }
  91.  
  92.  
  93.  
  94. int main()
  95. {
  96. int a,b,n;
  97. printf("Podaj przedział dolny: ");
  98. scanf("%d", &a);
  99. printf("Podaj przedział gorny: ");
  100. scanf("%d", &b);
  101. printf("Podaj ilosc prob: ");
  102. scanf("%d", &n);
  103. printf ("%6.2f", z2(a, b ,n));
  104. return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement