钻石图案是简单金字塔图案和倒金字塔图案的组合。
First Row: Display 1 Second Row: Display 1,2,3 Third Row: Display 1,2,3,4,5 Fourth Row: Display 1,2,3,4,5,6,7 Fifth Row: Display 1,2,3,4,5,6,7,8,9 Display the same contents from 4th Row till First Row below the fifth Row.
/* Program to print Diamond Pattern */
#include<stdio.h>
int main(){
int i,j,k;
clrscr();
printf("</p><p>");
printf("Diamond Pattern");
printf("</p><p>");
printf("</p><p>");
for(i = 1;i<=5;i++){
for(j = i;j<5;j++){
printf(" ");
}
for(k = 1;k<(i*2);k++){
printf("%d",k);
}
printf("</p><p>");
}
for(i = 4;i>=1;i--){
for(j = 5;j>i;j--){
printf(" ");
}
for(k = 1;k<(i*2);k++){
printf("%d",k);
}
printf("</p><p>");
}
getch();
return 0;
}
Shell本身是一个用C语言编写的程序,它是用户使用Linux的桥梁。Shell既是一种命令语言,又是一种程序设计语言。作为命令语言,它交互式地解释和执行用户输入的命令;作为程序设计语言,它定义了各种变量和参数,并提供了许多在高级语言中才具有的控制结构,包括循环和分支。它虽然不是Linux系统核心的一部分,但它调用了系统核心的大部分功能来执行程序、建立文件并以并行的方式协调各个程序的运行。因此,对于用户来说,shell是最重要的实用程序,深入了解和熟练掌握shell的特性极其使用方法,是用好Linux系统
24
以上就是在C语言中编写一个程序来打印菱形图案的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号