C++处理字符串真方便
#include <bits/stdc++.h> using namespace std; void print(int &n){ string border = "*"; string bottom(n+2,'*'); string empty(n,' '); for(int i=0;i<=n;i++){ if(i!=n){ cout << border + empty + border << endl; } else{ cout << bottom << endl << endl;; } } } int main(){ int n; while(cin>>n){ print(n); } return 0; }
0.0分
0 人评分