zoukankan      html  css  js  c++  java
  • DDA画直线

    #include "stdio.h"                          //用DDA法画直线,定义了直线始点(10,10*m+30)
    #include <graphics.h>
    main()
    {   float m;
     printf("the m is ");                //输入直线的斜率m
     scanf("%f",&m);
     
     if(abs(m)<=1)                      
     {
     int x;
        float y;
        int driver=DETECT,mode;
        initgraph(&driver,&mode,"c:\WINLibTC");
        y=10*m+30;
        for(x=10;x<=300;x++)
       {
         y=y+m;
        putpixel(x,y,4);
       }
       getch();
       closegraph(); 
       } 

       else
       {
         int y;
         float x;
        int driver=DETECT,mode;
        initgraph(&driver,&mode,"c\WINLibTC");
     
        for(y=10;y<=300;y++)
       {
         x=x+1/m;
        putpixel(x,y,4);
       }
       getch();
       closegraph();  
        
         }

    }

  • 相关阅读:
    go正则解析log文件
    go的堆排序
    golang实现websocket
    golang接口
    erlang时间操作
    golang函数
    golang for循环
    golang 条件语句if,switch
    golang内建变量类型
    区间存在幂个数
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/1964225.html
Copyright © 2011-2022 走看看