Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int tab[10]; // tworzy tablicy na 10 miejsc
- for( int a = 0; a < 10; a++)
- {
- tab[a] = rand() % 29 + 1;
- cout << "Liczba" << a << ": " << tab[a] << endl;
- }
- int najmniejszaLiczba = 30; // najmniejsza liczba obecnie to 30
- for( int a = 0; a < 10; a++)
- {
- if( tab[a] < najmniejszaLiczba)
- najmniejszaLiczba = tab[a]; // jesli liczba w tablicy jest mniejsza od obecnej najmniejszej to ja zamienia
- }
- cout << endl << "Najmniejsza liczba to: " << najmniejszaLiczba << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement