fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void solve() {
  6. int n;
  7. cin >> n;
  8.  
  9. if (n % 2 == 0) {
  10. cout << "That's La Peace\n";
  11. return;
  12. }
  13.  
  14. // Nửa trên
  15. for (int stars = 1; stars <= n; stars += 2) {
  16. int spaces = (n - stars) / 2;
  17.  
  18. for (int i = 0; i < spaces; i++) {
  19. cout << ' ';
  20. }
  21. for (int i = 0; i < stars; i++) {
  22. cout << '*';
  23. }
  24. cout << "\n";
  25. }
  26.  
  27. // Nửa dưới
  28. for (int stars = n - 2; stars >= 1; stars -= 2) {
  29. int spaces = (n - stars) / 2;
  30.  
  31. for (int i = 0; i < spaces; i++) {
  32. cout << ' ';
  33. }
  34.  
  35. for (int i = 0; i < stars; i++) {
  36. cout << '*';
  37. }
  38. cout << "\n";
  39. }
  40. }
  41.  
  42. int main() {
  43. ios_base::sync_with_stdio(false);
  44. cin.tie(NULL);
  45.  
  46. int t;
  47. if (cin >> t) {
  48. while (t--) {
  49. solve();
  50. }
  51. }
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
Standard output is empty