導航:首頁 > 源碼編譯 > 金字塔c語言編譯

金字塔c語言編譯

發布時間:2023-12-04 19:16:52

A. 請問金字塔用C語言怎麼編寫

#include <stdio.h>
#include <math.h>

int main()
{
int n;
int i,j;
n = 9;
for (i = 0; i < n; i++)
{
for (j = i; j < n - 1; j++)
printf(" ");// " "裡面是兩個空格
for (j = -i; j<= i; j++)
printf("%d ", i + 1 - abs(j));
printf("\n");
}
}

這個代碼就是正三角的,前面有空格,運行一下就知道了

B. c語言程序輸出數字金字塔

給,已經編譯運行通過:
#include<conio.h>
#include<stdio.h>

void main()
{
int n;//這個就是定義的你需要輸出的行數
int i,j;

printf("please input the n: ");
scanf("%d",&n);//輸入需要輸出的行數

for(i=0;i<n;i++)
{
for(j=0;j<2*(n-1-i);j++) printf(" ");
for(j=0;j<=i;j++) printf("%d",j+1);
for(j=0;j<2*i-1;j++) printf(" ");
for(j=i+1;j>0;j--)
{
if(i==0) break;
printf("%d",j);
}

printf("\n");
}

getch();
}

閱讀全文

與金字塔c語言編譯相關的資料

熱點內容
反編譯exe腳本 瀏覽:460
源碼文件夾怎麼編譯到固件中 瀏覽:910
ERp列印伺服器錯誤怎麼弄 瀏覽:111
蚌埠u盤加密軟體有哪些 瀏覽:178
前端如何認證伺服器 瀏覽:554
linux切換db2用戶命令 瀏覽:306
相片如何用電解壓 瀏覽:905
碩士程序員去學校當老師 瀏覽:120
pythonstr提取到字典 瀏覽:818
程序員那麼可愛有人看上陸漓了 瀏覽:876
php正則提取圖片 瀏覽:103
pythonlinuxdjango 瀏覽:562
php中文返回亂碼 瀏覽:89
宿舍裝的電信怎麼加密 瀏覽:745
為什麼壓縮文件解壓後變少了 瀏覽:426
現在安卓充電器普遍是什麼型號 瀏覽:714
9日均線36均線主圖指標源碼 瀏覽:349
程序員阿里文化完整版 瀏覽:98
早間新聞在哪個app上面可以看 瀏覽:954
工作啦app注冊的信息怎麼刪去 瀏覽:378