Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void ex2() {
- int i, chislo, n, x = 0;
- do
- {
- cout << " Введите количество чисел(n > 0) :\t";
- cin >> n;
- } while (n <= 0);
- int* mas = new int[n];
- for (i = 0; i < n; i++)
- {
- cout << i + 1 << " элемент : \t";
- cin >> mas[i];
- }
- cout << " Введите число для проверки ";
- cin >> chislo;
- cout << " На позиуиях: " << endl;
- for (i = 0; i < n; i++)
- {
- if (mas[i] == chislo){
- x++;
- cout << i+1 << " ";
- }
- }
- cout << " Данное число встречается в последовательности « << x << » раз(а) " << endl;
- }
- void ex1() {
- int x, y, z, temp;
- cout << "x= ";
- cin >> x;
- cout << "y= ";
- cin >> y;
- z = x + y;
- int* arr1 = new int[x];
- int* arr2 = new int[y];
- int* arr3 = new int[z];
- for (int i = 0; i < x; i++) {
- cin >> arr1[i];
- }
- for (int i = x - 1; i >= 1; i--) {
- for (int j = 0; j < i; j++) {
- if (arr1[j] > arr1[j + 1]) {
- temp = arr1[j];
- arr1[j] = arr1[j + 1];
- arr1[j + 1] = temp;
- }
- }
- }
- temp = 0;
- for (int i = 0; i < y; i++) {
- cin >> arr2[i];
- }
- for (int i = y - 1; i >= 1; i--) {
- for (int j = 0; j < i; j++) {
- if (arr2[j] > arr2[j + 1]) {
- temp = arr2[j];
- arr2[j] = arr2[j + 1];
- arr2[j + 1] = temp;
- }
- }
- }
- temp = 0;
- for (int i = 0; i < z; i++) {
- if (i < x) {
- arr3[i] = arr1[i];
- }
- else {
- arr3[i] = arr2[i - x];
- }
- }
- for (int i = z - 1; i >= 1; i--) {
- for (int j = 0; j < i; j++) {
- if (arr3[j] > arr3[j + 1]) {
- temp = arr3[j];
- arr3[j] = arr3[j + 1];
- arr3[j + 1] = temp;
- }
- }
- }
- for (int i = 0; i < z; i++) {
- cout << arr3[i] << " ";
- }
- cout << endl;
- delete arr1;
- delete arr2;
- delete arr3;
- }
- int main() {
- setlocale(0, "");
- // ex1();
- // ex2();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment