Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
105887 罗迎甲 打印菱形 C++ Accepted 2 MS 276 KB 569 2025-01-14 16:37:35

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int i,n,k,a; cin>>n; for(i=1;i<=n;i++){ for(k=1;k<=n-i;k++) cout<<" "; for(a=1;a<=i*2-1;a++) cout<<"*"; cout<<endl; } for(int z=1;z<=n-1;z++){ for(int x=1;x<=z;x++) cout<<" "; for(int x=1;x<=2*(n-z)-1;x++) cout<<"*"; cout<<endl; } return 0; }