Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <time.h>
- int main()
- {
- int a, b, c, d, e;
- printf("podaj 5 liczb dodatnich w zakresie od 1 do 100\n");
- scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
- if( 1 > a|| a > 100|| 1 > b|| b > 100|| 1 > c|| c > 100|| 1 > d|| d > 100|| 1 > e|| e > 100)
- { printf(" conajmniej jedna z liczb nie spelnia zalozen\n"); }
- else {
- printf("liczby wypisane : %d %d %d %d %d\n", a, b, c, d, e);
- srand( time(NULL));
- int x1, x2, x3, x4, x5;
- x1 = rand()%100+1;
- x2 = rand()%100+1;
- x3 = rand()%100+1;
- x4 = rand()%100+1;
- x5 = rand()%100+1;
- printf( "liczby wylosowane : %d %d %d %d %d\n", x1, x2, x3, x4, x5);
- printf("liczby powtarzajace sie:\t");
- int ile_sie_powtarza = 0;
- if( a == b) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == c) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == d) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == e) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == x1) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == x2) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == x3) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == x4) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( a == x5) {printf("%d\t", a); ile_sie_powtarza += 1;};
- if( b == c) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == d) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == e) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == x1) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == x2) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == x3) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == x4) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( b == x5) {printf("%d\t", b); ile_sie_powtarza += 1;};
- if( c == d) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( c == e) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( c == x1) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( c == x2) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( c == x3) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( c == x4) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( c == x5) {printf("%d\t", c); ile_sie_powtarza += 1;};
- if( d == e) {printf("%d\t", d); ile_sie_powtarza += 1;};
- if( d == x1) {printf("%d\t", d); ile_sie_powtarza += 1;};
- if( d == x2) {printf("%d\t", d); ile_sie_powtarza += 1;};
- if( d == x3) {printf("%d\t", d); ile_sie_powtarza += 1;};
- if( d == x4) {printf("%d\t", d); ile_sie_powtarza += 1;};
- if( d == x5) {printf("%d\t", d); ile_sie_powtarza += 1;};
- if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
- if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
- if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
- if( e == x1) {printf("%d\t", e); ile_sie_powtarza += 1;};
- if( x1 == x2) {printf("%d\t", x1); ile_sie_powtarza += 1;};
- if( x1 == x3) {printf("%d\t", x1); ile_sie_powtarza += 1;};
- if( x1 == x4) {printf("%d\t", x1); ile_sie_powtarza += 1;};
- if( x1 == x5) {printf("%d\t", x1); ile_sie_powtarza += 1;};
- if( x2 == x3) {printf("%d\t", x2); ile_sie_powtarza += 1;};
- if( x2 == x4) {printf("%d\t", x2); ile_sie_powtarza += 1;};
- if( x2 == x5) {printf("%d\t", x2); ile_sie_powtarza += 1;};
- if( x3 == x4) {printf("%d\t", x3); ile_sie_powtarza += 1;};
- if( x3 == x5) {printf("%d\t", x3); ile_sie_powtarza += 1;};
- if( x4 == x5) {printf("%d\t", x4); ile_sie_powtarza += 1;};
- if(ile_sie_powtarza ==0) {printf("nic sie nie powtarza");}
- printf("\n");
- double sredniak, srednial;
- sredniak = ( a + b + c + d + e)/5;
- srednial = ( x1 + x2 + x3 + x4 + x5)/5;
- if( srednial > sredniak ) { printf("srednia aryt. liczb wylosowanych jest wieksza od sredniej aryt. licz wypisanych\n"); }
- else if( srednial == sredniak) { printf("srednia wylosowanych i wypisanych jest rowna\n"); }
- else { printf(" srednia wylosowanych jest mniejsza od sredniej wypisanych");}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement