当前位置:首页>开发>正文

C语言代码结果和注释 vc 代码注释

2023-05-07 23:13:12 互联网 未知 开发

 C语言代码结果和注释 vc  代码注释

C语言代码结果和注释

#include
#define f(x)x*x*x
main()
{
  int a=3,s,t
  s=f(a 1)   // 相当于 s = 3 1*3 1*3 1 
  t=f((a 1)) // 相当于 t = (3 1)*(3 1)*(3 1) 
  printf("%d,%d",s,t)
}

vc 代码注释

#include"iostream.h"
int main()
{
int a=0,b=1,c=2 //初始化变量
switch(a) //对a进行判断
{
case 0: //当 a =0 时
cout< {
a=a b*c //b乘c在加上a 后赋值给a ,a = 0 1*2 = switch(a)
{
case 2: // 当a = 2时,输出b c =1 2= cout< case 5: // 当a = 5时,输出a=a b*c =2 1*2= 4
cout<<(a=a b*c)< default: //缺省的情况下 c=2*2 =4;
c=c*2
break
}
}
default: //缺省的情况下输出a b c = 4 1 4 = cout< break
}
return 0
}

c语言程序代码注释

int driver=EGA,mode=1\将来要设置显示模式是EGA模式1,现在只是把模式定下来

 int data[]={7,3,12,6,9,5,8,11}\数组

 int i,j,xstep=70,ystep=20\i j是循环计数器 剩下2个是步长 看样子要画图用

 char buffer[10] \字符缓存?

 initgraph (&driver,&mode,"")\现在正式打开图形模式

 line(40,10,40,310)\画直线分别是起点坐标和终点坐标

 line(40,310,540,310)\同上

 j=310

 settextjustify(CENTER_TEXT,CENTER_TEXT) \调整文本位置,从这个位置开始显示字

  for(i=0i<=15i )

   {line(20,j,40,j)\画线

   itoa(i,buffer,10)\这个函数自己查应该是图形模式下输出字串的

   outtextxy(10,j,buffer)\同上

   j-=ystep \调整步长,继续出字

   }

   j=40

   settextjustify(CENTER_TEXT,TOP_TEXT) \换个位置出字

   for(i=0i<=8i )

    {

    setfillstyle(i 1,i 4)\设置填充模式

    line(j,320,j,310)\画线或者画方块

    itoa(i,buffer,10)

    outtextxy(j,330,buffer)

    if(i!=8)

    {

    bar(j,(310-(data[i]*ystep)),j xstep,310-1)\画方块

    rectangle(j,(310-data[i]*ystep),j xstep,310)\圆角矩形

    }

    j =xstep

    }

    getch()

    closegraph()关闭图形模式回到字符模式(不清屏)

}

大体上就这样了。不清楚的地方到turboc2.0内按F1查询或者查看程序其他部分。

C#代码要求注释及结果

static void Main(string[] args)//入口函数main

{
int count=0//定义count的值为整形0
for(int i=4i>0i--)//for循环,从i=4开始递减,i<=0时中断,一共循环4次
{
for(int j=0j<6j )//for循环,从j=0开始递增,j>=6时中断 ,一共循环6次

{
count //变量count的值加 }
console.writeline(count)//输出count的值
}
}
输出结果应该是:6 12 18 24