编写程序输入以下图案,行数由输入的n决定 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 ... 1 2 3 4 5 ...n
这用两个for循环写就可以
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;
#pragma warning(disable:4996)
#include <iostream>
#include <string>
using namespace std;
int main() {
int n = 0;
scanf("%d",&n);
for (int i = 1; i < n; i++) {
int j = 1;
while (j < i) {
printf("%d ", j);
j++;
}
printf("\n");
}
}
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632