閱讀601 返回首頁    go 阿裏雲 go 技術社區[雲棲]


C++打印“*”圖案例子

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;
	}
}


最後更新:2017-04-02 22:16:39

  上一篇:go 使用github管理iOS分布式項目開發
  下一篇:go pl /sql導入導出表結構,表數據,sql腳本