fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void charrepeat(char c, int n) {
  5. for (int i = 0; i < n; i ++) {
  6. cout << c;
  7. }
  8. }
  9.  
  10. void margin (int n) {
  11. charrepeat('*', n);
  12. cout << endl;
  13. }
  14.  
  15. void middle (int n) {
  16. cout << '*';
  17. charrepeat('$', n - 2);
  18. cout << '*';
  19. cout << endl;
  20. }
  21.  
  22. void middle_multiple(int n){
  23. for (int i; i < n - 2; i++) {
  24. middle(n);
  25. }
  26. }
  27.  
  28. int main(){
  29. int n;
  30. cin >> n;
  31. if (n == 1){
  32. cout << "*";
  33. }
  34. margin(n);
  35. middle_multiple(n);
  36. margin(n);
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5320KB
stdin
51
stdout
***************************************************
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*
*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