當前位置:首頁 » 編程語言 » c語言列印數字圖形

c語言列印數字圖形

發布時間: 2025-09-11 19:09:42

c語言:輸入行數n,及首個小寫字母,輸出Z型字母圖形,如果輸出超過z,再回到a,依次循環下去

代碼文本:

#include "stdio.h"

int main(int argc,char *argv[]){

char ch,n,i,j,t;

printf("Input line number and a letter... ");

if(scanf("%d %c",&n,&ch)!=2 || ch<'a' || ch>'z'){

printf("Input error, exit... ");

return 0;

}

for(ch-='b',i=0;i<n;i++)

putchar((++ch%=26)+'a');

putchar(' ');

for(t=n-2,i=0;i<t;i++){

for(j=0;j<t-i;putchar(' '),j++);

putchar((++ch%=26)+'a');

putchar(' ');

}

for(i=0;i<n;i++)

putchar((++ch%=26)+'a');

putchar(' ');

return 0;

}

㈡ C語言編程 列印數字字元圖案 輸入任意整數n,輸出n行由數字構成的三角形字元陣列圖形。

C語言程序如下:

#includestdio.h

intmain()

{

inta=0;//從0開始。

intn;//輸入的行數,每行的字元數

scanf(%d,n);

while(n)//括弧內n表示n!=0.

{

inti;

for(i=0;in;i++)////注意n隨著while循環變化的,n在不停的減少,

{

a++;

printf(a+「);//每個字元後面都有一個空格。

}

n--;

printf(」 );//輸入一行之後,換行。

}

return0;

}

/iknow-pic.cdn.bcebos.com/b812c8fcc3cec3fd0eb25993d888d43f8694274c"target="_blank"title="點擊查看大圖"class="illustration_alink">/iknow-pic.cdn.bcebos.com/b812c8fcc3cec3fd0eb25993d888d43f8694274c?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto"esrc="//www.ultimate-communications.com/img_b812c8fcc3cec3fd0eb25993d888d43f8694274c"/>

(2)c語言列印數字圖形擴展閱讀:

思路:

輸入格式:輸入在一行中給出一個正整數n(1≤n≤10)。

輸出格式:輸出n行由0開始構成的三角形字元陣列。格式見輸出樣例,其中每個數字後面都有一個空格。需要輸出的數字超過9時,重新從0開始循環。

輸入樣例:7

輸出樣例:

0123456
789012
34567
8901
234
56
7

㈢ c語言,輸出由數字組成的菱形圖形。求如何編寫。謝謝!

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
intmain()
{
inti=0;
intj=0;
intn;
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf("");
}
for(j=1;j<=2*i-1;j++)
{
printf("%d",i);
}
for(j=0;j<abs(n/2-i);j++)
{
printf("");
}
printf(" ");
}

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

㈣ 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();
}

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:583
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:877
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:572
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:758
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:674
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1001
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:245
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:104
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:796
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:702