Search
 
SCRIPT & CODE EXAMPLE
 

CPP

flag of georgia

#include <iostream>
using namespace std;
 
int main() {
	
	int k;
	cin >> k;
    int n = 4 * k + 14;
    

		/**
		* to set cross inside squeres we should identifu 1/4 point and after that the another starts will below, above, right and left from it 
		*/

		//first half
    for (int i = 0; i < n / 2; i++) {
        if (i == 0 || i == n / 2 - 1) {
            for (int j = 0; j < n; j++) {
                cout << "*";
            }
        } else {
            for(int j = 0; j < n; j++) {
                if (j == 0 || j == n - 1 || j == n/2 || j == n/2 - 1) {
                    cout << "*";
                } else if (i == n/4 && (j == n/4 || j == 3 * n/4 || j == n/4 - 1 || j == n/4 + 1 || j == 3 * n/4 - 1 || j == 3 * n/4 +1)) {
                    cout << "*";
                } else if (i == n/4 -1 && (j == n/4 || j == 3 * n/4)) {
                    cout << "*";
                } else if (i == n/4 + 1 && (j == n/4 || j == 3 * n/4)) {
                    cout << "*";
                } else {
                    cout << " ";
                }
            }
        }
        cout << endl;
    }
		//second half
    for (int i = 0; i < n / 2; i++) {
        if (i == 0 || i == n / 2 - 1) {
            for (int j = 0; j < n; j++) {
                cout << "*";
            }
        } else {
            for(int j = 0; j < n; j++) {
                if (j == 0 || j == n - 1 || j == n/2 || j == n/2 - 1) {
                    cout << "*";
                } else if (i == n/4 && (j == n/4 || j == 3 * n/4 || j == n/4 - 1 || j == n/4 + 1 || j == 3 * n/4 - 1 || j == 3 * n/4 +1)) {
                    cout << "*";
                } else if (i == n/4 -1 && (j == n/4 || j == 3 * n/4)) {
                    cout << "*";
                } else if (i == n/4 + 1 && (j == n/4 || j == 3 * n/4)) {
                    cout << "*";
                } else {
                    cout << " ";
                }
            }
        }
        cout << endl;
    }
 
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ delete printed characters 
Cpp :: inline function in cpp 
Cpp :: count number of char in a string c++ 
Cpp :: how to extract a folder using python 
Cpp :: integer max value c++ 
Cpp :: c++ convert to assembly language 
Cpp :: len in cpp 
Cpp :: how to run cpp using gcc vscode 
Cpp :: C++ to specify size and value 
Cpp :: time complexity 
Cpp :: C++ float and double Using setprecision() For Floating-Point Numbers 
Cpp :: c++ linked list 
Cpp :: how we can write code to remove a character in c++ 
Cpp :: how to rotate a matrix 90 degrees clockwise 
Cpp :: nth fibonacci number 
Cpp :: how to modify 2d array in function c++ 
Cpp :: queue 
Cpp :: c++ segmentation fault 
Cpp :: cpprestsdk send file 
Cpp :: C++ Vector Initialization method 03 
Cpp :: store arbitrarly large vector of doubles c++ 
Cpp :: coinPiles 
Cpp :: ejemplo 
Cpp :: sfml disable message 
Cpp :: texorpdfstring math in title latex 
Cpp :: Types of Triangles Based on Angles in c++ 
Cpp :: C++ Multilevel Inheritance 
Cpp :: sqrt function in c++ 
Cpp :: como copiar codigo de c++ con numeros de fila en docs 
Cpp :: fishes code in assignment expert 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =