Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Project_Permutation_Nikolay_Georgiev.cpp : Defines the entry point for the console application.
- //
- //Nikolay Georgiev Georgiev
- //F92875
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- #include <cstdbool>
- using namespace std;
- //zadachi 1 i 2 избираме функция 3x
- //fillarray
- int fillTheArray(int ** arr, int rows, int colls);
- int FillSecondRow(int ** arr, int rows, int colls);
- int printTheArray(int ** arr, int rows, int colls);
- bool IsInnection(int ** arr, int rows, int colls);
- int main()
- {
- int rows = 2;
- int colls;
- cout << "Enter number of columns: " << endl;
- cin >> colls;
- int ** arr = new int*[rows];
- fillTheArray(arr, rows, colls);
- FillSecondRow(arr, rows, colls);
- printTheArray(arr, rows, colls);
- IsInnection(arr, rows, colls);
- }
- int fillTheArray(int ** arr, int rows, int colls) {
- for (int i = 0; i < rows; i++)
- {
- arr[i] = new int[colls];
- }
- for (int j = 0; j < colls; j++)
- {
- cin >> arr[0][j];
- }
- return 0;
- }
- int FillSecondRow(int ** arr, int rows, int colls) {
- int temp;
- for (int i = 0; i < rows-1; i++)
- {
- for (int j = 0; j < colls; j++)
- {
- arr[i + 1][j] = arr[i][j];
- }
- }
- for (int j = 0; j < colls; j++)
- {
- temp = arr[1][j];
- temp *= 3;
- arr[1][j] = temp;
- }
- return 0;
- }
- int printTheArray(int ** arr, int rows, int colls) {
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < colls; j++)
- {
- cout << arr[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
- bool IsInnection(int ** arr, int rows, int colls) {
- for (int i = 0; i < rows; i++)
- {
- int temp;
- for (int j = 0; j < colls; j++)
- {
- temp = arr[i][j];
- for (int k = 1; j < colls; j++)
- {
- if (temp == arr[i][k]) {
- cout << "Innection : true";
- return true;
- }
- else {
- cout << "Innection : false";
- return false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement