Quick actions

cmd+k|ctrl+k

Navigation

Languages

LAB7_1020

Snippet info

Language

Cpp

Visibility

public

Author

maloy-

Created

2018-12-04T16:53:23Z

Updated

2018-12-04T16:53:23Z

#include <iostream>
using namespace std;
const int n = 6 ; 
int main() {
    
    int a[n][n];
    
    for (size_t i = 0 ; i < n ; i++){
        for (size_t j = 0 ; j< n ; j++){
            a[i][j] = 6 -  rand( ) % 10 ; 
            if (a[i][j] >= 0 )
            cout << " " << a[i][j] << "   " ;
            else cout <<  a[i][j] << "   " ;
        }
        cout << endl ; 
        
    }
    
    int k = 0 ; 
    //bool sign = true ; 
    
    for (size_t i = 0 ; i < n ; i++){
        for (size_t j = 0 ; j< n ; j++){
            if ((( a[i][j] >= 0 ) && ( a[i+1][j+1] < 0 )) or (( a[i][j] < 0 ) && ( a[i+1][j+1] >= 0 ))){
                //sign = false ;
                k++;
            }
            else continue ; 
        }
    }
    
    cout << " Количество смены знаков =  " << k << endl ; 
    return 0;
}
INFO