Cod sursa(job #1333664)

Utilizator wGEORGEWGeorge Cioti wGEORGEW Data 3 februarie 2015 14:27:29
Problema Oras Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <fstream>
 
const char IN [ ] = "oras.in" ;
const char OUT [ ] = "oras.out" ;
const int MAX = 214 ;
 
using namespace std;
 
ifstream fin ( IN ) ;
ofstream fout ( OUT ) ;
 
int mat [ MAX ] [ MAX ] ;
 
int main(              )
{
    int n , add;
    fin >> n ;
    if ( n & 1 )
        add = 2 ;
    else add = 3 ;
    for ( int i = 1 ; i < n ; ++ i )
        for ( int j = i + 1 ; j <= n ; ++ j )
            mat [ i ] [ j ] = 1 ;
    for ( int i = 1 ; i <= n ; ++ i )
        for ( int j = i - add ; j >= 1 ; -- j )
        {
            mat [ i ] [ j ] = 1 ;
            mat [ j ] [ i ] = 0 ;
        }
    if ( ( n & 1 ) == 0 ){
        mat [ 3 ] [ n ] = 1 ;
        mat [ n ] [ 3 ] = 0 ;
    }
    for ( int i = 1 ; i <= n ; ++ i ){
        for ( int j = 1 ; j <= n ; ++ j )
            fout << mat [ i ] [ j ] ;
        fout << '\n' ;
    }
    return 0;
}