hdoj2565 放大的X ;有关for循环的

来源:互联网 发布:sql having用法 编辑:程序博客网 时间:2024/06/07 06:01

http://acm.hdu.edu.cn/showproblem.php?pid=2565


#include<iostream>#include<string>using namespace std;int main(){int t;int a;cin >> t;while (t--){cin >> a;for (int n = 0; n < a / 2; n++){  //上部for (int j = 0; j < n; j++)cout << " ";cout << "X";for (int i = 0; i <a - 2*(n+1); i++)  cout << " ";cout << "X";cout << endl;}for (int n = 0; n < a / 2; n++){  //中部cout << " ";}cout << "X" << endl;for (int n = a / 2; n > 0; n--){//下部for (int j = n - 1; j > 0; j--){//wencout << " ";}cout << "X";for (int i = a - 2 * n; i > 0; i--)cout << " ";cout << "X" << endl;}cout << endl;}}


for循环可以“逆序”使用


0 0
原创粉丝点击