网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 计算机等考二级C语言学习要领
内容
    1、计算机语言挺枯燥的,如何提起兴趣
    答:首先要明确学习的目标,没有明确的学习目标就没有学习动力。给自己定一个目标,比如这次一定通过计算机等级考试,或者这个月学习完做个东西出来等等。其次,确定了目标之后,要认真去做,多上机操作实践,遇到不懂的要多跟教师和其他学员交流,千万不能放弃。当自己编的一段小程序运行通过,或攻下一道难题,自己就会获得一种成就感,可能还会很兴奋,也就渐渐有了兴趣。最后,要把所学的知识运用到实际问题当中,这样既可以巩固所学的知识,不至于完学了就忘,还可以根据实际需要拓展知识面。这样良性循环,兴趣也会越来越浓。
    2、有学员来信问到:我的电脑里安装的TURBO?C(970K)不能正常的编译,现象是:在编译过程中,提示没有错误也没有警告,按任意键返回,可是在电脑上不能生成"OBJ"文件,有时提示:Unable to open input file’cos.obj’,我的朋友从他们学校的PC上拷贝回来的程序也出现这个问题?!在他们学校却很正常,这是怎么回事?这个问题一直在困扰我,使我的学习不能进行下去!请帮我解决。谢谢!
    答:这需要重新设置options--directories中的include目录和lib目录,设为你C的安装目录就可以了。记住要保存哟!
    3、#include
    main()
    {int m=7,n=4;
    float a=38.4,b=6.4,x;
    x=m/2+n*a/b+1/2;
    printf("%f\n",x);
    }
    这个程序的结果是27.000000
    为什么我一直算的是28.000000呢?请指教
    答:main()
    {
    int m=7,n=4;
    float a=38.4,b=6.4,x;
    x=m/2+n*a/b+1/2;
    printf("%f\n",x);
    }
    m/2==3;因为m是整形所以结果为整形不是3.5而是3
    同样1/2不是0.5而是0。
    要改的话,x=(float)m/2+n*a/b+1.0/2.0;
    结果为28.0000
    4、有些人说我的程序很难让人看懂,请问如何将程序写得规范、简洁明了
    答:这是编程中重要的一点,要养成良好的编程习惯。请看一个例题:程序很简单,是用TURBO C编一个时钟程序。具体如下:
    /****************************************************
    Module:clock.c
    just a test of my programming ability
    *****************************************************/
    #include"math.h"
    #include"dos.h"
    #include"stdio.h"
    #include"graphics.h"
    main()
    {
    char s[30];
    int gdriver,gmode;
    int cosh,sinh,cosm,sinm,coss,sins;
    struct ;time t;
    char keydown=0;
    int x=300,y=160,r=40;
    clrscr();
    gdriver=9; gmode=1;
    initgraph(&gdriver,&gmode,"a:\\");/*需要说明的是,第三个参数a:\\是egavga.bgi这个文件的路径*/
    /* install the graphic device.the third parameter is the path of the driver*/
    setbkcolor(0);
    setcolor(WHITE);
    while(1)
    {
    circle(x,y,r);/*paintthecircle*/
    line(x,y+r-10,x,y+r-12);
    line(x+r-4,y,x+r,y);
    line(x-r,y,x-r+4,y);
    line(x,y-r+10,x,y-r+10+2); /* draw the fout scales */
    gettime(&t);
    sprintf(s,"The current time is %2d:%02d:%02d\n",t.ti_hour,t.ti_min,t.ti_sec,t);
    outtextxy(0,0,s); /* out put the current time */
    outtextxy(0,10,"This clock is written by lijun"); /*?show the auther */
    coss=(int)((r-10)*cos(t.ti_sec*3.14f/30-3.14f/2)+x);
    sins=(int)((r-10)*sin(t.ti_sec*3.14f/30-3.14f/2)+y);
    cosm=(int)((r-19)*cos(t.ti_min*3.14f/30-3.14f/2)+x);
    sinm=(int)((r-19)*sin(t.ti_min*3.14f/30-3.14f/2)+y);
    cosh=(int)((r-28)*cos((t.ti_hour+(float)(t.ti_min)/60)*3.14f/6-3.14f/2)+x);
    sinh=(int)((r-28)*sin((t.ti_hour+(float)(t.ti_min)/60)*3.14f/6-3.14f/2)+y);
    /* calculate the position of the three points */
    setcolor(14);
    line(x,y,coss,sins);
    setcolor(13);
    line(x,y,cosm,sinm);
    setcolor(10);
    line(x,y,cosh,sinh);
    setcolor(15);
    /* draw the points */
    sleep(1);
    clrscr();&nb
    sp;
    keydown=kbhit();/* check whether key down */
    if(keydown)
    {
    closegraph();/* close graphic device */
    exit(0);
    }
    }
    }
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/17 21:16:37