本帖最後由 李泳霖 於 2024-1-30 14:06 編輯
- #include<iostream>
- using namespace std;
- int main()
- {
- int a;
- cout<<"請輸入一個整數(1~3):";
- cin>>a;
- if(a==1)
- {
- cout<<"*"<<endl;
- cout<<"**"<<endl;
- cout<<"***"<<endl;
- cout<<"****"<<endl;
- cout<<"******"<<endl;
- }
- if(a==2)
- {
- cout<<" *"<<endl;
- cout<<" ***"<<endl;
- cout<<" *****"<<endl;
- cout<<" *******"<<endl;
- cout<<"**********"<<endl;
- }
- if(a==3)
- {
- cout<<"******"<<endl;
- cout<<" ******"<<endl;
- cout<<" ******"<<endl;
- cout<<" ******"<<endl;
- cout<<" ******"<<endl;
- }
- return 0;
- }
複製代碼 |