Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- #include <iomanip>
- using namespace std;
- const int n = 3;
- const int k = 1.5 * 59;
- void randomGen(int mas[]);
- int hashing(int a);
- void print(int mas[]);
- int main()
- {
- setlocale(0, "");
- int hash[k];
- int mas[n];
- randomGen(mas);
- print(mas);
- for (int i = 0; i < n; i++)
- cout << mas[i] << endl << hashing(mas[i]) << endl;
- system("pause");
- }
- int hashing(int a)
- {
- return a*a / 10 % 10;
- }
- void randomGen(int mas[])
- {
- srand(time(0));
- for (int i = 0; i < n; i++)
- {
- mas[i] = 10 + rand() % 90;
- for (int j = 0; j < i; j++)
- if (mas[i] == mas[j])
- i--;
- }
- }
- void print(int mas[])
- {
- for (int i = 0; i < n; i++) {
- if (i < 9) {
- cout << setw(3) << "[0" << i + 1 << "]";
- cout << setw(5) << mas[i];
- }
- else {
- if (i % 10 == 0)
- cout << endl;
- cout << setw(2) << "[" << i + 1 << "]";
- cout << setw(5) << mas[i];
- }
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement