下面是一个用C语言打印正三角形的示例代码: #include <stdio.h> int main() { int rows, i, j, space; printf("请输入要打印的行数:"); scanf("%d", &rows); for (i = 1; i <= rows; i++) { // 打印空格 for (space = 1; space <= rows - i; space++) { printf(" "); } /...
include <stdio.h> main(){ int i,j,k;int n;scanf("%d",&n);//正三角 for(i=0;i<n;i++){ for(j=0;j<n-i;j++)printf(" ");for(k=0;k<=i;k++)printf(" *");printf("\n");} //倒三角 for(i=0;i<n;i++){ for(j=0;j<=i;j++)printf(" ");for(k=0;...
int main() { int i, j, n = 0, a[17][17] = {0};while (n < 16) { printf("请输入杨辉三角形的行数:");scanf("%d", &n);} for (i = 0; i < n; i++) { a[i][0] = 1;} for (i = 1; i < n; i++) { for (j = 1; j <= i; j++) { a[i][...