Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int FN[25], N;
- int n;
- void masiv()
- {
- do {
- cout << "\n Choose how many FN do u want: (no more than 25)\n";
- cin >> N;
- } while (N<0 || N>25);
- for (int i = 0; i < N; i++)
- {
- cout << "\n FN[" << i + 1 << "]=";
- cin >> FN[i];
- }
- }
- template <class T>
- T bubble_sort_array(T array[], size_t array_size, bool type = false) {
- for (size_t i = 0; i < array_size - 1; i++) {
- for (size_t j = i + 1; j < array_size; j++)
- if ((type ? (array[i] > array[j]) : (array[i] < array[j]))) {
- T temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
- }
- return *array;
- }
- void odd()
- {
- for (int i = 0; i < 10; i++)
- {
- if (FN[i] % 2 == 1)
- cout << FN[i] << "\n";
- }
- }
- int maxi(int *ind)
- {
- int m = FN[0];
- for (int i = 1; i < N; i++)
- if (m < FN[i])
- {
- m = FN[i]; *ind = i + 1;
- }
- return m;
- }
- void print(int *m, int *ind)
- {
- for (int i = 0; i < N; i++)
- cout << FN[i] << "\t";
- cout << "\n \n";
- cout << "\n Max=" << *m << endl;
- cout << "\n Position:" << *ind << endl;
- }
- void main()
- {
- int ch, i, max, index, F[25];
- do {
- cout << "\n \t Menu \n";
- cout << "\n 1.Input FN (do 25) \n";
- cout << "\n 2.ODD FN \n";
- cout << "\n 3.Finding max FN and shows its position \n";
- cout << "\n 4.Sort ascending \n";
- cout << "\n 5.Shows information \n";
- cout << "\n 6.Exit \n";
- do { cout << "\n your choice is:"; cin >> ch; } while (ch<1 || ch>6);
- switch (ch)
- {
- case 1:masiv(); break;
- case 2:odd(); break;
- case 3:max = maxi(&index); cout << "\n Max FN=" << max << " on pos:" << index << endl; break;
- case 4:
- bubble_sort_array<int>(FN, N, true);
- for (size_t i = 0; i < N; i++)
- cout << FN[i] << endl;
- break;
- case 5:print(&max, &index); break;
- }
- } while (ch != 6);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement