#include <iostream> using namespace std; void Print(int l, int n, int odd) { if ((n + 1) == l) return; if ((odd % 2) == 0) { switch (l % 9) { case 1: cout << "********* *********" << endl; break; case 2: cout << "* ** ** * * ** ** *" << endl; break; case 3: cout << "********* *********" << endl; break; case 4: cout << "*** *** *** ***" << endl; break; case 5: cout << "* * * * * * * *" << endl; break; case 6: cout << "*** *** *** ***" << endl; break; case 7: cout << "********* *********" << endl; break; case 8: cout << "* ** ** * * ** ** *" << endl; break; case 0: cout << "********* *********" << endl; odd += 1; break; } } else if((odd %2) == 1) { switch (l % 9) { case 1: cout << "***************************" << endl; break; case 2: cout << "* ** ** ** ** ** ** ** ** *" << endl; break; case 3: cout << "***************************" << endl; break; case 4: cout << "*** ****** ****** ***" << endl; break; case 5: cout << "* * * ** * * ** * * *" << endl; break; case 6: cout << "*** ****** ****** ***" << endl; break; case 7: cout << "***************************" << endl; break; case 8: cout << "* ** ** ** ** ** ** ** ** *" << endl; break; case 0: cout << "***************************" << endl; odd += 1; break; } } Print(l + 1, n, odd); } int main() { int N; cin >> N; Print(1, N, 1); return 0; }
# include < iostream > # include < vector > using namespace std ; int Num_of_Divisor ( int n ) { int Count = 0 ; for ( int i = 1 ; i < = n ; i + + ) if ( n % i = = 0 ) Count + + ; return Count ; } int main ( ) { int Testcase ; cin > > Testcase ; while ( Testcase - - ) { int Rooms ; cin > > Rooms ; vector < int > Prisons ; for ( int i = 0 ; i < Rooms ; i + + ) Prisons . push_back ( 0 ) ; for ( int i = 1 ; i < Prisons . size ( ) + 1 ; i + + ) { if ( ( Num_of_Divisor ( i ) % 2 ) = = 0 ) Prisons [ i - 1 ] = 0 ; else Prisons [ i - 1 ] = 1 ; } int Fleer = 0 ; for ( int i = 0 ; i < Prisons . size ( ) ; i + + ) if ( Prisons ...
댓글
댓글 쓰기