Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- task 1
- /*#include <iostream>
- using namespace std;
- void deleteMatrix ( int** matrix , int n )
- {
- for ( int i=0 ; i<n ; i++ )
- {
- delete[] matrix[i];
- }
- delete[] matrix;
- }
- bool compareClms ( int** matrix , int N , int Iindex , int Jindex )
- {
- for ( int i=0 ; i<N ; i++ )
- {
- if ( matrix[i][Iindex] != matrix[N-i][Jindex] )
- {
- return false;
- }
- }
- return true;
- }
- int main()
- {
- int N,M;
- cout << " write the indexes of the matrix ";
- cin >> N >> M;
- int** matrix = new (nothrow) int* [N];
- if ( matrix != nullptr )
- {
- for ( int i=0 ; i<N ; i++ )
- {
- matrix[i] = new (nothrow) int[M];
- if ( matrix[i] == nullptr )
- {
- deleteMatrix(matrix,N);
- }
- }
- cout << " fill the matrix " << N << "X" << M << endl;
- for ( int i=0 ; i<N ; i++ )
- {
- for ( int j=0 ; j<M ; j++ )
- {
- cin >> matrix[i][j];
- }
- }
- int cntr = 0;
- for( int i=0 ; i<M ; i++ )
- {
- int j=M-i;
- if ( compareClms(matrix,N,i,j) )
- {
- cout << i << " " << j << endl;
- cntr ++ ;
- }
- }
- if ( cntr == 0 )
- {
- cout << " NO! " << endl;
- }
- }
- deleteMatrix(matrix,N);
- return 0;
- }
- */
- task 2
- /*#include<iostream>
- using namespace std;
- bool compareHelper (unsigned int n1 ,unsigned int n2 )
- {
- if ( n2 < 0 )
- {
- return false;
- }
- if ( n1 % 10 != n2 % 10 )
- {
- return compareHelper(n1,n2 /10);
- }
- else
- {
- return true;
- }
- }
- bool compare ( unsigned int num1,unsigned int num2 )
- {
- if ( num1 < 10 && num2 && num1 == num2 )
- {
- return true;
- }
- if ( compareHelper(num1,num2) )
- {
- return compare(num1/10,num2);
- }
- else
- {
- return false;
- }
- }
- int main () {
- unsigned int num1,num2;
- cout << " write 2 numbers ";
- cin >> num1 >> num2;
- if( num1 > num2 )
- {
- swap(num1,num2);
- }
- if ( compare(num1,num2) )
- {
- cout << " yes ";
- }
- else
- {
- cout << " no ";
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement