本文目錄一覽:
c語言講解!
//頭文件載入
#include math.h //數學支持
#include graphics.h //圖形支持
#include stdlib.h //輸入輸出支持
#include time.h //時間處理支持
//主函數部份
void main(void)
{
//圖形驅動設定
int gdriver=DETECT,gmode ;
//變量聲明
int ran_number ;
float a,b,c,d,e,f ;
float x,y,x_pre,y_pre ;
float disp_x,disp_y ;
//圖形驅動初始化
initgraph(gdriver,gmode,”\\tc”);
/* setfillstyle(SOLID_FILL,RED);//設定樣式*/
randomize(); //隨機數處理
setbkcolor(BLUE); //設定背景顏色為藍色
setcolor(14); //設定前景色為紅色
x=y=x_pre=y_pre=0 ; //初始變量值
ran_number=90 ;
while(kbhit()==0)
{
ran_number=random(100)+1 ; //從1-100中取隨機數
if(ran_number==1)
{
a=0 ;
b=0 ;
c=0 ;
d=0.15 ;
e=0 ;
f=0 ;
}
else if(ran_number1ran_number=86)
{
a=0.87 ;
b=0.014 ;
c=-0.014 ;
d=0.87 ;
e=0 ;
f=1.6 ;
}
else if(ran_number86ran_number=93)
{
a=0.26 ;
b=0.472 ;
c=0.772 ;
d=0.34 ;
e=0 ;
f=1.6 ;
}
else
{
a=0.28 ;
b=0.867 ;
c=-0.478 ;
d=0.4 ;
e=0 ;
f=0.44 ;
}
x=a*x_pre*cos(b)-d*sin(c)*y_pre+e ;
y=c*x_pre*sin(b)+d*cos(c)*y_pre+f ;
x_pre=x ;
y_pre=y ;
disp_x=(x+5)*639/12 ;
disp_y=350-y*28 ;
putpixel((int)disp_x,(int)disp_y,GREEN); //在屏幕上(disp_x,disp_y)的位置上畫綠色的點。這裡都換成了整形的。
}
getch();
getch(); //暫停
closegraph(); //關閉圖形驅動
}
這是我所知的部分,至於他畫的是什麼我就不曉得了,好感像是數學圖形吧,弧的可能是最大的,不過這個表達式我沒見過,數學沒學好
(入門級)C語言程序 看不懂,求詳細講解注釋
#includestdio.h
int main()
{ chars[ ]=”GFEDCBA”; //一個字符串s
int p=6; //p為6
while(s[p]!=『D』) //s[6]開始循環,即從A開始滿足條件打印。接着是s[5]即B也滿足,然後是s[4]即C也滿足。然後是D不滿足退出循環
{ printf(“%c “, s[p]); //打印s[p]字符
p=p-1; } //p減少1,即往前面移動
return 0;
}
輸出是ABC,我看不懂程序意思,求每行注釋。
還有一題:
main()
{ int n1,n2; //兩個整數
scanf(“%d”,n2); //輸入n2
while(n2!=0) //當n2不為0
{ n1=n2%10; //n1為n2的個位數字
n2=n2/10; //n2/10消除掉個位
printf(“%d “,n1); } } //打印n1即n2的個位數字
//整個程序的含義就是將數字123打印成 3 2 1
C語言 C++和VC VC++什麼區別?
C語言、C++、VC、VC++的區別如下:
1、C語言: 一門計算機語言,用於人與計算機溝通。
2、C++: 一門計算機語言,用於人與計算機溝通,比C更強大。
3、VC和VC++可以看成一個東西,VC++是指一個IDE。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/282708.html