fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int nr;
  6. cin >> nr;
  7. for (int i = 0; i < nr; ++i) {
  8. for (int j = 0; j < nr; ++j) {
  9. if (i == 0 && j == nr - 1) {
  10. cout << "*" << "\n";
  11. } else if (i == 0 || i == nr - 1) {
  12. cout << "*";
  13. }
  14. if ((i != 0 && i != nr - 1) && j == nr - 1) {
  15. cout << "*" << "\n";
  16. } else if ((i != 0 && i != nr - 1) && (j == 0 || j == nr - 1)) {
  17. cout << "*";
  18. } else if (i != 0 && i != nr - 1) {
  19. cout << "$";
  20. }
  21. }
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5288KB
stdin
1





stdout
*