12 条题解
-
4lichengjun LV 10 @ 2023-3-29 18:01:31
#include <iostream> using namespace std; int n; void one(){ for(int i=1;i<=n;i++)cout<<"*"; cout<<endl; } void md(int x,int k){ for(int j=1;j<=x;j++)cout<<"*"; for(int j=1;j<=k;j++)cout<<" "; for(int j=1;j<=x;j++)cout<<"*"; cout<<endl; } int main(){ cin>>n; one(); int x=n/2,k=1; for(int i=1;i<=n/2;i++){ md(x,k); x--; k+=2; } x+=2; k-=4; for(int i=1;i<=n/2-1;i++){ md(x,k); x++; k-=2; } one(); return 0; }
-
32022-1-12 11:52:13@
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int n; cin>>n; n/=2; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } }
-
12022-1-12 12:02:04@
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int n; cin>>n; n/=2; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } }
-
02024-12-2 21:58:06@
#include<bits/stdc++.h> using namespace std; int main(){ int n,left,right; cin>>n; int center=n/2; for(int i=0;i<n;i++){ left=abs(center-i); right=center-left+center; for(int j=0;j<n;j++){ if(j<=left||j>=right){ cout<<'*'; }else{ cout<<" "; } } cout<<endl; } return 0; }
-
02024-11-18 22:12:03@
#include <bits/stdc++.h> using namespace std; int n; int main() { cin>>n; for(int i=1;i<=n;i++)cout<<"*"; for(int i=n/2;i>=1;i--){ cout<<endl; for(int j=1;j<=i;j++)cout<<"*"; for(int j=1;j<=n-2*i;j++)cout<<" "; for(int j=1;j<=i;j++)cout<<"*"; } for(int i=2;i<=n/2;i++){ cout<<endl; for(int j=1;j<=i;j++)cout<<"*"; for(int j=1;j<=n-2*i;j++)cout<<" "; for(int j=1;j<=i;j++)cout<<"*"; } cout<<endl; for(int i=1;i<=n;i++)cout<<"*"; return 0; }
-
02023-6-2 19:53:06@
#include <iostream> #include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; int main() { int n; cin>>n; int zhong=n/2+1,bu=0; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { if(i==1 || i==n) { cout<<'*'; } else { if(j<=zhong+bu && j>=zhong-bu) cout<<' '; else cout<<'*'; } } cout<<"\n"; if(i==1 || i==n) { bu=0; } else { if(i<zhong) bu++; if(i>=zhong) bu--; } } }
-
02023-3-19 18:05:26@
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int n; cin>>n; n/=2; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } }
-
02022-1-12 12:09:03@
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int n; cin>>n; n/=2; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } }
-
-12023-3-25 18:46:52@
#include<bits/stdc++.h> using namespace std; int main() { int n,t=1; cin>>n; for(int i=1; i<=n; i++) cout<<""; cout<<endl; for(int i=2; i<=n/2; i++) { for(int j=1; j<=(n-t)/2; j++) cout<<""; for(int j=1; j<=t; j++) cout<<" "; for(int j=1; j<=(n-t)/2;j++) cout<<""; cout<<endl; t+=2; } for(int i=2; i<=n/2+1; i++) { for(int j=1; j<=(n-t)/2; j++) cout<<""; for(int j=1; j<=t; j++) cout<<" "; for(int j=1; j<=(n-t)/2; j++) cout<<""; cout<<endl; t-=2; } for(int i=1; i<=n; i++) cout<<""; return 0; }
-
-12023-3-25 18:46:11@
-
-12023-3-19 20:15:15@
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int main() { int n; cin>>n; n/=2; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<""; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<""; } } cout<<endl; }
-
- }
-
-
-22022-1-12 12:02:48@
#include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int main() { int n; cin>>n; n/=2; for(int i=1;i<=n+1;i++) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } for(int i=n;i>=1;i--) { for(int j=1;j<=n*2+1;j++) { if(n-i+2<j&&n+i>j) { cout<<" "; } else { cout<<"*"; } } cout<<endl; } }
- 1
信息
- ID
- 953
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 372
- 已通过
- 213
- 上传者