Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6. int a, b, c, d, e;
  7. printf("podaj 5 liczb dodatnich w zakresie od 1 do 100\n");
  8. scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
  9. if( 1 > a|| a > 100|| 1 > b|| b > 100|| 1 > c|| c > 100|| 1 > d|| d > 100|| 1 > e|| e > 100)
  10. { printf(" conajmniej jedna z liczb nie spelnia zalozen\n"); }
  11. else {
  12.  
  13.  
  14. printf("liczby wypisane : %d %d %d %d %d\n", a, b, c, d, e);
  15.  
  16. srand( time(NULL));
  17. int x1, x2, x3, x4, x5;
  18. x1 = rand()%100+1;
  19. x2 = rand()%100+1;
  20. x3 = rand()%100+1;
  21. x4 = rand()%100+1;
  22. x5 = rand()%100+1;
  23.  
  24. printf( "liczby wylosowane : %d %d %d %d %d\n", x1, x2, x3, x4, x5);
  25. printf("liczby powtarzajace sie:\t");
  26.  
  27. int ile_sie_powtarza = 0;
  28. if( a == b) {printf("%d\t", a); ile_sie_powtarza += 1;};
  29. if( a == c) {printf("%d\t", a); ile_sie_powtarza += 1;};
  30. if( a == d) {printf("%d\t", a); ile_sie_powtarza += 1;};
  31. if( a == e) {printf("%d\t", a); ile_sie_powtarza += 1;};
  32. if( a == x1) {printf("%d\t", a); ile_sie_powtarza += 1;};
  33. if( a == x2) {printf("%d\t", a); ile_sie_powtarza += 1;};
  34. if( a == x3) {printf("%d\t", a); ile_sie_powtarza += 1;};
  35. if( a == x4) {printf("%d\t", a); ile_sie_powtarza += 1;};
  36. if( a == x5) {printf("%d\t", a); ile_sie_powtarza += 1;};
  37. if( b == c) {printf("%d\t", b); ile_sie_powtarza += 1;};
  38. if( b == d) {printf("%d\t", b); ile_sie_powtarza += 1;};
  39. if( b == e) {printf("%d\t", b); ile_sie_powtarza += 1;};
  40. if( b == x1) {printf("%d\t", b); ile_sie_powtarza += 1;};
  41. if( b == x2) {printf("%d\t", b); ile_sie_powtarza += 1;};
  42. if( b == x3) {printf("%d\t", b); ile_sie_powtarza += 1;};
  43. if( b == x4) {printf("%d\t", b); ile_sie_powtarza += 1;};
  44. if( b == x5) {printf("%d\t", b); ile_sie_powtarza += 1;};
  45. if( c == d) {printf("%d\t", c); ile_sie_powtarza += 1;};
  46. if( c == e) {printf("%d\t", c); ile_sie_powtarza += 1;};
  47. if( c == x1) {printf("%d\t", c); ile_sie_powtarza += 1;};
  48. if( c == x2) {printf("%d\t", c); ile_sie_powtarza += 1;};
  49. if( c == x3) {printf("%d\t", c); ile_sie_powtarza += 1;};
  50. if( c == x4) {printf("%d\t", c); ile_sie_powtarza += 1;};
  51. if( c == x5) {printf("%d\t", c); ile_sie_powtarza += 1;};
  52. if( d == e) {printf("%d\t", d); ile_sie_powtarza += 1;};
  53. if( d == x1) {printf("%d\t", d); ile_sie_powtarza += 1;};
  54. if( d == x2) {printf("%d\t", d); ile_sie_powtarza += 1;};
  55. if( d == x3) {printf("%d\t", d); ile_sie_powtarza += 1;};
  56. if( d == x4) {printf("%d\t", d); ile_sie_powtarza += 1;};
  57. if( d == x5) {printf("%d\t", d); ile_sie_powtarza += 1;};
  58. if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
  59. if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
  60. if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
  61. if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
  62. if( x1 == x2) {printf("%d\t", x1); ile_sie_powtarza += 1;};
  63. if( x1 == x3) {printf("%d\t", x1); ile_sie_powtarza += 1;};
  64. if( x1 == x4) {printf("%d\t", x1); ile_sie_powtarza += 1;};
  65. if( x1 == x5) {printf("%d\t", x1); ile_sie_powtarza += 1;};
  66. if( x2 == x3) {printf("%d\t", x2); ile_sie_powtarza += 1;};
  67. if( x2 == x4) {printf("%d\t", x2); ile_sie_powtarza += 1;};
  68. if( x2 == x5) {printf("%d\t", x2); ile_sie_powtarza += 1;};
  69. if( x3 == x4) {printf("%d\t", x3); ile_sie_powtarza += 1;};
  70. if( x3 == x5) {printf("%d\t", x3); ile_sie_powtarza += 1;};
  71. if( x4 == x5) {printf("%d\t", x4); ile_sie_powtarza += 1;};
  72. if(ile_sie_powtarza ==0) {printf("nic sie nie powtarza");}
  73. printf("\n");
  74.  
  75. double sredniak, srednial;
  76.  
  77. sredniak = ( a + b + c + d + e)/5;
  78. srednial = ( x1 + x2 + x3 + x4 + x5)/5;
  79. if( srednial > sredniak ) { printf("srednia aryt. liczb wylosowanych jest wieksza od sredniej aryt. licz wypisanych\n"); }
  80. else if( srednial == sredniak) { printf("srednia wylosowanych i wypisanych jest rowna\n"); }
  81. else { printf(" srednia wylosowanych jest mniejsza od sredniej wypisanych");}
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement