LOGO
首页 小说列表 排行榜 搜索

    C语言教程-第65页

  • 第1页
  • 上一页
  • 下一页

    温馨提醒:系统正在全面升级。您可以访问最新站点。谢谢!

      int num=20,i;

      int top,bottom;

      initgraph(&driver,&mode,"");

      top=y-30;

      bottom=y-30;

      for(i=0;i

      {

      ellipse(250,250,0,360,top,bottom);

      top-=5;

      bottom+=5;

      }

      getch();

      }

      ==============================================================

      【程序64】

      题目:利用ellipse and rectangle 画图。

      1.程序分析:

      2.程序源代码:

      #include "stdio.h"

      #include "graphics.h"

      #include "conio.h"

      main()

      {

      int driver=VGA,mode=VGAHI;

      int i,num=15,top=50;

      int left=20,right=50;

      initgraph(&driver,&mode,"");

      for(i=0;i

      {

      ellipse(250,250,0,360,right,left);

      ellipse(250,250,0,360,20,top);

      rectangle(20-2*i,20-2*i,10*(i+2),10*(i+2));

      right+=5;

      left+=5;

      top+=10;

      }

      getch();

      }

      ==============================================================

      【程序65】

      题目:一个最优美的图案。   

      1.程序分析:

      2.程序源代码:

      #include "graphics.h"

      #include "math.h"

      #include "dos.h"

      #include "conio.h"

      #include "stdlib.h"

      #include "stdio.h"

      #include "stdarg.h"

      #define MAXPTS 15

      #define PI 3.1415926

      struct PTS {

      int x,y;

      };

      double AspectRatio=0.85;

      void LineToDemo(void)

      {

      struct viewporttype vp;

      struct PTS points[MAXPTS];

      int i, j, h, w, xcenter, ycenter;

      int radius, angle, step;

      double rads;

      printf(" MoveTo / LineTo Demonstration" );

      getviewsettings( &vp );

      h = vp.bottom - vp.top;

      w = vp.right - vp.left;

      xcenter = w / 2; /* Determine the center of circle */

      ycenter = h / 2;

      radius = (h - 30) / (AspectRatio * 2);

      step = 360 / MAXPTS; /* Determine # of increments */

      angle = 0; /* Begin at zero degrees */

      for( i=0 ; i

      rads = (double)angle * PI / 180.0; /* Convert angle to radians */

      points[i].x = xcenter + (int)( cos(rads) * radius );

      points[i].y = ycenter - (int)( sin(rads) * radius * AspectRatio );

      angle += step; /* Move to next increment */

      }

      circle( xcenter, ycenter, radius ); /* Draw bounding circle */

      for( i=0 ; i

      for( j=i ; j

      moveto(points[i].x, points[i].y); /* Move to beginning of cord */

      lineto(points[j].x, points[j].y); /* Draw the cord */

      } } }

      main()

      {int driver,mode;

      driver=CGA;mode=CGAC0;

      initgraph(&driver,&mode,"");

      setcolor(3);

      setbkcolor(GREEN);

      LineToDemo();}

      ==============================================================

      【程序66】

      题目:输入3个数a,b,c,按大小顺序输出。   

      1.程序分析:利用指针方法。

      2.程序源代码:

      /*pointer*/

      main()

      {

      int n1,n2,n3;

      int *pointer1,*pointer2,*pointer3;

  • 第1页
  • 上一页
  • 下一页