2 条题解
-
3
已AC,放心食用
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; for(int i = 1 ; i <= n ; i++){ for(int h = 1 ; h < n-i+1 ; h++)cout << ' ' ; if(i == 1 || i == n)for(int l = 1 ; l <= i*2-1 ; l++)cout << '*' ; else{ cout << '*' ; for(int j = 1 ; j < i*2-2 ; j++)cout << ' ' ; cout << '*' ; } cout << endl ; } return 0; }
-
1
#include <iostream> using namespace std; int n ; int cal ( int x ) { if ( x == 1 ) { for ( int i = 1; i <= n - x ; i++ ) cout << " " ; cout << "" ; } else { for ( int i = 1; i <= n - x ; i++ ) cout << " " ; cout << "" ; for ( int i = 1 ; i <= ( x - 1 ) * 2 - 1 ; i++ ) cout << " " ; cout << "" ; } } int main() { cin >> n ; for ( int i = 1 ; i <= n ; i++ ) { if ( i == n ) for ( int j = 1 ; j <= ( n - 1 ) * 2 + 1 ; j++ ) cout << "" ; else cal(i) ; cout << endl ; } return 0 ; }
- 1
信息
- ID
- 225
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 1
- 标签
- 递交数
- 42
- 已通过
- 32
- 上传者