arrow_forward
همه ارسالها
جزئیات ارسال کد#294
برای پسندیدن وارد شوید
1#include <iostream>
2using namespace std;
3int main()
4{
5 int n , first_line , last_line , middle_lines , all_spaces1 , all_spaces2 ;
6 cin >> n;
7 first_line = 0;
8 last_line = 0;
9 middle_lines = 0;
10 all_spaces1 = 0;
11 all_spaces2 = n - 3;
12
13
14 while ( first_line < n )
15 {
16 cout <<"*";
17 first_line ++;
18 }
19
20 cout <<'\n';
21
22 while ( middle_lines < n - 2 )
23 {
24 cout <<"*";
25
26 int left_spaces = 0;
27 while (left_spaces < all_spaces1)
28 {
29 cout <<" ";
30 left_spaces ++;
31 }
32
33 cout <<"*";
34
35 int right_spaces = 0;
36 while (right_spaces < all_spaces2)
37 {
38 cout <<" ";
39 right_spaces ++;
40 }
41
42 all_spaces1 ++;
43 all_spaces2 --;
44
45 cout <<"*";
46 cout <<'\n';
47 middle_lines ++;
48 }
49
50 while ( last_line < n )
51 {
52 cout <<"*";
53 last_line ++;
54 }
55
56
57
58
59 return 0;
60}
کد ارسالشده برای داوری خودکار هاتکدز
UTF-8