#include "Simple_window.h"
#include "Graph.h"
#include <math.h>
#include <iostream>
#include <limits>
using namespace std;
int main(){
Simple_window win(Point(100,100),600,400,"Marks");
Graph_lib::Polygon poly;
bool over = true;
int n = 0;
while(over){
Marks pp("x");
pp.add(Point(300,200));
cout<<"Enter number of sides (3 or more): ";
while(!(cin>>n)){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout<<"Enter number of sides (3 or more): ";
}
if(n<3){
break;
}
//Finding the angle and number of sides...
if(n%2 != 0){
//logic for polygon...
}
}else{
//logic for polygon...
}
}
poly.set_color(Color::magenta); // adjust properties of poly
win.attach (poly); // connect poly to the window
win.attach(pp);
win.wait_for_button(); // Display!
}
}
이 프로그램은 n-sided polygon을 만드는가? 다각형을 설정 한 후. 나는 그것을 다시하고 싶다. 난 다각형의 양을 입력 한 후. "다음"을 클릭하면 얼마나 많은 폴리곤이 다시 묻히고 프로세스가 반복되는지 묻습니다. 누군가 내가 전화를 걸라고했습니다. 그러나 나는 그것을 입력하는 방법을 잘 모르겠다. 삭제 poly.points 에서처럼? 또는 다각형을 삭제 하시겠습니까? 몇 가지 시도했지만 오류가 계속 발생했습니다.메모리 할당을 해제하고 다시 할당하십시오. FLTK의 다각형 재설정하기
내 두 번째 질문은 38 행입니다. 원래는 입력 했으므로 3보다 작은 숫자를 입력하면 프로그램이 종료됩니다. 그러나 프로그램은 끝나지 않을 것입니다. 그래서 나는 휴식을 취해야했다.
if(n<3){
over=false;
cout<<"why wont this end ?"<<endl;
}
부울 이상을 참으로 설정합니다. 진정한 루프. n < 3 이상은 거짓입니다. 따라서 프로그램을 끝내시겠습니까? 끝나지 않을거야.
정말 고마워요. 한 번만 더 질문합니다. Simple_window win (포인트 (100,100), 600,400, "마크"); 제목 안에 int를 넣을 수 있습니까? 5 "마크"와 같이); ? "따옴표"만 사용하는 것 같습니다. 제목에 문자열을 삽입하는 방법이 있습니까? –
질문을 이해할 수 없습니다 – cup
내가 원하는면을 여러 개 입력하면. n-sided 다각형을 말하도록 팝업 창이 나타납니다. n은 입력 한 번호입니다. –