開啟MicroSoft Visual C++ ,新建一個 C++ source file檔案,具體命令為“檔案”→“新建”,在彈出的對話方塊中選擇“檔案”選項卡,選擇 C++ source file,命名檔案將以下程式碼複製到新建的檔案中,#include<iostream>using namespace std;#define MidpointLine(r)void main(){ int r;cout<<"請輸入r"<<endl;cin>>r;int x,y,d;x=0;y=r;d=1-r;cout<<"x"<<" "<<"y"<<" "<<"d"<<endl;cout<<x<<" "<<y<<" "<<d<<endl;while(x<y){if(d<0){d+=2*x+3;x++;}else{ d+=2*(x-y)+5;x++;y--;}cout<<x<<" "<<y<<" "<<d<<endl;} /*while*/} /*MidpointLine*/ “組建”→“開始除錯”→“GO!”,在彈出的對話方塊中都單擊確定。除錯完畢,輸入r的值,比如輸入r=125
開啟MicroSoft Visual C++ ,新建一個 C++ source file檔案,具體命令為“檔案”→“新建”,在彈出的對話方塊中選擇“檔案”選項卡,選擇 C++ source file,命名檔案將以下程式碼複製到新建的檔案中,#include<iostream>using namespace std;#define MidpointLine(r)void main(){ int r;cout<<"請輸入r"<<endl;cin>>r;int x,y,d;x=0;y=r;d=1-r;cout<<"x"<<" "<<"y"<<" "<<"d"<<endl;cout<<x<<" "<<y<<" "<<d<<endl;while(x<y){if(d<0){d+=2*x+3;x++;}else{ d+=2*(x-y)+5;x++;y--;}cout<<x<<" "<<y<<" "<<d<<endl;} /*while*/} /*MidpointLine*/ “組建”→“開始除錯”→“GO!”,在彈出的對話方塊中都單擊確定。除錯完畢,輸入r的值,比如輸入r=125