输出10*10的星星
打印星星图,如图所示:
问题求解:
#include<iostream>;
using namespace std;
int main() {
//方法一
cout << "* * * * * * * * * *" << endl;//1
cout << "* * * * * * * * * *" << endl;//2
cout << "* * * * * * * * * *" << endl;//3
cout << "* * * * * * * * * *" << endl;//4
cout << "* * * * * * * * * *" << endl;//5
cout << "* * * * * * * * * *" << endl;//6
cout << "* * * * * * * * * *" << endl;//7
cout << "* * * * * * * * * *" << endl;//8
cout << "* * * * * * * * * *" << endl;//9
cout << "* * * * * * * * * *" << endl;//10
cout << "-------------------" << endl;//分割符号
//方法二
for (int i = 1; i <= 10; i++) {
cout << "* * * * * * * * * *" << endl;
}
cout << "-------------------" << endl;//分割符号
//方法三
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10;j++) {
if (j < 10) {
cout << "* ";//不换行输出
}
else {
cout << "*" << endl;
}
}
}
system("pause");
return 0;
}