當前位置:首頁 » 編程語言 » c語言中鑽石

c語言中鑽石

發布時間: 2022-08-04 00:34:46

Ⅰ 在c語言中,diamond是什麼意思

diamond在C語言中沒有特別的含義,既不是關鍵字也不是庫函數的函數名。

可能是編程人員自定義的一個變數名或函數名。

舉例如下:
int diamond; // 定義一個int類型的變數,變數名為diamond
double diamond; // 定義一個double類型的變數,變數名為diamond
int diamond(int a, int b) // // 自定義一個函數,函數名為diamond
{
return a+b;
}

Ⅱ C語言數組輸出一個鑽石圖形的程序有小問題,在線等啊

錯誤有兩個:
1.char diamond[][5]={{' ',' ','*'},{' ','*',' ','*'},{'*',' ',' ',' ','*'},{' ','*',' ','*'},{' ',' ','*'}};這個結束處的分號改成英文的。
2.少一個 「}」。

Ⅲ 怎麼用C語言打鑽石圖

#include <iostream>
using namespace std;
int main()
{
int i,j,k,num; //定義for循環中的變數 i,j,k 。num是菱形的個數。
int N; //定義菱形的寬度。

cout<<"Please enter the width of the diamend:"<<endl<<"N=";
cin>>N;
while(N%2==0) //判斷輸入的菱形寬度是否為奇數,若是奇數則正確,若是偶數則錯誤。
{
cout<<"The number you entered is wrong!"<<endl;
cout<<"Please try again:"<<endl;
cin>>N;
}

char c;
cout<<"The number is right!"<<endl<<"請輸入構成菱形的字元(字元必須是單個的)."<<endl;
cout<<"The sign is:";
cin>>c;

cout<<"請輸入你想輸出的菱形的個數!"<<endl;
cout<<"The number is:";
cin>>num;

for(int n=0;n<num;n++) //最外層for循環開始,控制菱形個數
{
for(i=0;i<(N+1)/2;i++) //顯示菱形的上半部分
{
for(j=0;j<(N+1)/2-i-1;j++) //顯示空格
{
cout<<" ";
}
for(j=0;j<2*i+1;j++) //顯示構成菱形的字元
{
cout<<c;
}
cout<<endl;
}
/* 注釋:display
*
***
*****
******* */

for(k=i;k<N;k++) //顯示菱形的下半部分
{
for(j=0;j<k-i+1;j++) //顯示空格
{
cout<<" ";
}
for(j=0;j<2*N-2*k-1;j++) //顯示構成菱形的字元

{
cout<<c;
}
cout<<endl;
}
/* 注釋:display
*****
***
*
*/
cout<<endl;
} //最外層for循環結束
return 0;
}

以前寫的注釋也很詳細,只是跟你的還是有點區別,自己研究下把

Ⅳ C語言用*來輸出鑽石形狀 應該咋寫

#include<stdio.h>
void main ()
{
int i;
int j;

for(i = 1;i <= 4;i ++)
{
for(j = 1;j < 5 - i;j ++)
{
printf(" ");
}

for(j = 1;j <= 2 * i - 1;j ++)
{
printf(" *");
}

printf("\n");
}

for(i = 3;i > 0;i --)
{
for(j = 1;j < 5 - i;j ++)
printf(" ");
for(j = 1;j <= 2 * i - 1;j ++)
printf(" *");
printf("\n");
}
}

Ⅳ C語言,畫鑽石圖

#include
char info(void)
{
char C;
printf("this program will show you a diamond shape, please input a charactor:");
scanf("%c",&C);
return C;
}
void diamond(char C)
{
printf("\n");
printf("3個空格%c\n",C);
printf("2個空格%c%c%c\n",C,C,C);
printf("一個空格%c%c%c%c%c\n",C,C,C,C,C);
printf("%c%c%c%c%c%c%c\n",C,C,C,C,C,C,C);
printf("一個空格%c%c%c%c%c\n",C,C,C,C,C);
printf("2個空格%c%c%c\n",C,C,C);
printf("3個空格%c",C);
}
void main()
{
clrscr();
diamond(info());/*diamond所需的參數由info()得到,在main()中不必設變數*/
getch();
}

Ⅵ 用C語言編寫鑽石

#include<stdio.h>

int main()

{ int m,n,j;

for(m=6;m<=8;m++)

{ for(n=1;n<=8-m;n++)

printf(" ");

for(j=1;j<=2*m-1;j++)

printf("* ");

printf(" ");

}

for(m=7;m>=1;m--)

{

for(n=1;n<=8-m;n++)

printf(" ");

for(j=1;j<=2*m-1;j++)

printf("* ");

printf(" ");

}

system("pause");

return 0;

}

Ⅶ c語言輸出鑽石圖形的思路

#include<stdio.h>
char info(void)
{
char C;
printf("this program will show you a diamond shape, please input a charactor:");
scanf("%c",&C);
return C;
}
void diamond(char C)
{
printf("\n");
printf("3個空格%c\n",C);
printf("2個空格%c%c%c\n",C,C,C);
printf("一個空格%c%c%c%c%c\n",C,C,C,C,C);
printf("%c%c%c%c%c%c%c\n",C,C,C,C,C,C,C);
printf("一個空格%c%c%c%c%c\n",C,C,C,C,C);
printf("2個空格%c%c%c\n",C,C,C);
printf("3個空格%c",C);
}
void main()
{
clrscr();
diamond(info());/*diamond所需的參數由info()得到,在main()中不必設變數*/
getch();
}

熱點內容
建立多級文件夾 發布:2025-03-13 00:13:34 瀏覽:723
存儲器價格 發布:2025-03-13 00:12:14 瀏覽:759
編譯原理上下文無關文法例題 發布:2025-03-13 00:12:12 瀏覽:93
微視頻腳本怎麼寫 發布:2025-03-12 23:59:54 瀏覽:609
蘋果手機文件夾管理 發布:2025-03-12 23:59:12 瀏覽:98
了解排序演算法 發布:2025-03-12 23:58:06 瀏覽:26
華為平板tf存儲設置 發布:2025-03-12 23:57:20 瀏覽:315
python設置目錄 發布:2025-03-12 23:57:12 瀏覽:956
xp怎麼查看系統密碼 發布:2025-03-12 23:57:12 瀏覽:280
菱智哪個配置最好 發布:2025-03-12 23:56:37 瀏覽:225