c语言编写程序输出下列三角形 1111111 11111
时间: 2023-08-24 16:21:46 浏览: 84
以下是使用 C 语言编写的程序实现该三角形输出:
```c
#include <stdio.h>
int main() {
printf("1111111\n");
printf(" 11111\n");
return 0;
}
```
输出结果为:
```
1111111
11111
```
相关问题
C语言编写程序,输出下列三角形
好的,以下是使用C语言编写的程序,可以输出下列三角形:
```
*
**
***
****
*****
```
```
*
**
***
****
*****
```
```
*
***
*****
*******
*********
```
程序如下:
```
#include <stdio.h>
int main() {
int i, j;
// 输出第一个三角形
printf("第一个三角形:\n");
for (i = 1; i <= 5; i++) {
for (j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
// 输出第二个三角形
printf("\n第二个三角形:\n");
for (i = 1; i <= 5; i++) {
for (j = 1; j <= 5 - i; j++) {
printf(" ");
}
for (j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
// 输出第三个三角形
printf("\n第三个三角形:\n");
for (i = 1; i <= 5; i++) {
for (j = 1; j <= 5 - i; j++) {
printf(" ");
}
for (j = 1; j <= 2 * i - 1; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
```
程序运行结果如下:
```
第一个三角形:
*
**
***
****
*****
第二个三角形:
*
**
***
****
*****
第三个三角形:
*
***
*****
*******
*********
```
编写c语言程序要求输出下列三角形: 1 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4
以下是输出该三角形的C语言程序:
```c
#include <stdio.h>
int main() {
int rows = 4; // 三角形的行数
int i, j;
for (i = 1; i <= rows; i++) {
// 输出空格
for (j = 1; j <= rows - i; j++) {
printf(" ");
}
// 输出数字
for (j = 1; j <= 2 * i - 1; j++) {
printf("%d ", i);
}
printf("\n");
}
return 0;
}
```
程序运行结果:
```
1
2 2 2
3 3 3 3 3
4 4 4 4 4 4 4
```
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)