C++打印如下图案:
*
***
*****
*******
*****
***
*
#include <iostream> using namespace std; int main(int argc, char **argv) { for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 2*i-1; j++) { cout<<"*"; // 输出*号 } cout<<endl; } for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 7-(2*i); j++) { cout<<"*"; // 输出*号 } cout<<endl; } }