Esempio n. 1
0
int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    Calculate w;
    w.show();

    return a.exec();
}
Esempio n. 2
0
void multiplyTest() {
        Calculate calc;
        int first = 5;
        int second = 5;

        ASSERTM("Multiplication was incorrect!", 25 == calc.multiply(first, second));
}
Esempio n. 3
0
//--------1 输出表达式; 
void Print::PrintStringQueue(string input) 
{
	/*创建Scan对象s*/ 
	Scan s;
	Calculate c;
	/*获得Scan里所扫描的队列*/                                            
	queue<string> tmp = s.ToStringQueue(input);  
	
	//---- 除数为0或超出十位数输ERROR 
	if (s.IsError() == true )
	{
		cout << "ERROR" <<endl;
	}
	else 
	{
		if (c.iserror() == false) 
		{
			/*依次输出符合要求的元素*/
			while ( !tmp.empty() )
			{
				cout << tmp.front() ;
				tmp.pop();                                  
			}
			cout << " " << c.Calculater(input);
		}
		else
		{
			cout << "ERROR" << endl;
		}	
	}
}
Esempio n. 4
0
void subTest() {
        Calculate calc;
        int first = 5;
        int second = 3;

        ASSERTM("Subtraction was incorrect!", 2 == calc.sub(first, second));
}
Esempio n. 5
0
void sumTest() {
        Calculate calc;
        int first = 5;
        int second = 5;

        ASSERTM("Summation was incorrect!", 10 == calc.sum(first, second));

}
Esempio n. 6
0
//-----3 采用文件读取的方法
void Print::Usedfile(string input, string read, string ans)
{
	Calculate c;
	Scan ss;
	
	//---- 3-1 文件声明及打开; 
	ifstream in;
	ofstream out;
	
	//调用.c_str()接受字符串作为文件名;
	in.open (read.c_str(),ios::in );
	out.open(ans.c_str() ,ios::out); 
	//----3-2 文件的读写;
	while ( !in.eof() )
	{
		int flag1 = 0;
		input.clear();
		getline(in, input, '\n');	
		double answer = 0;
		//---- 3-2-1 判断是否超出十位; 
		if (ss.IsError() == true)
		{
			flag1 = 1;
//			out << "ERROR" << endl;
		}
		 
		if (ss.IsError() == false)
		{
			answer = c.Calculater(input);
			
			//---- 3-2-2 判断除数是否为0; 
			if (c.iserror() == true )
			{
				out << "ERROR" << endl;
			}
			else
			{
				//---- 3-2-3 输出答案; 
				if (flag1 == 1)
				{
					out << "ERROR" << endl;
					flag1 = 0;
				}
				else
				{
					out << answer << endl;	
				}
				
			}
		}
	}
	//-----3-3 关闭文件; 
	in.close() ;
	out.close();
}
Esempio n. 7
0
int main(int argc, const char * argv[]) {
    string input;
    bool p,a;
    double ans;
    int i;
    Scan scan;
    Print print;
    Calculate Calculate;
    
    p=false;
    a=false;
    i=1;
    
//    getline(cin,input);
    
    if (argc<2) return 0;
    
    input=argv[i];
    
    while (1){
        
        if (input=="-a") {
            input=argv[++i];
            a=true;
            continue;
        }
        
        if (input=="-p"){
            input=argv[++i];
            p=true;
            continue;
        }
        
        break;
    }
    

// print.PrintStringQueue( scan.ToStringQueue(input) );
    
    
    ans=Calculate.getAns( scan.ToStringQueue(input) , p);
    
    if (a) cout<<input<<"=";
    cout<<ans<<endl;
    return 0;
}
Esempio n. 8
0
int main()
{
	Calculate calculate;

	cout << "Pleas input Radius:";
	cin >> calculate.rad;

	if (calculate.rad <= 0)
	{
		cout << "Error!" << endl;
	}
	else
	{
		cout << "Area is " << calculate.cal(calculate.rad) << endl;
	}

	return 0;
}
Esempio n. 9
0
//-----2 输出结果; 
void Print::Printanswer(string input)
{
	Calculate c;
	Scan s;
	double answer = 0;
	answer = c.Calculater(input);
	if (s.IsError() == true)
	{
		cout << "ERROR" << endl;
	}
	else
	{
		if (c.iserror() == false)
		{
			cout << answer << endl;
		}
		else
		{
			cout << "ERROR" << endl;
		}
	} 
	
}
int main(int argc, char **argv) {
    int diff, old_score, new_score;
    struct timeval start;
    gettimeofday(&start,NULL);
    Shapes s;
    s.readFile(argc, argv);
    s.buildConflictArray();
    Graphs g;
    g.buildConflictGraph(s.getShapes());
    s.findBoundingBox();
    Windows w;
    w.createWindow();
    w.countArea(s.getShapes(), g.getGraphs());
    g.countTotalColorDiff();

    Calculate c;
    //c.printResult(s.getShapes(), g.getGraphs(), w.getWindows(), argc, argv);
    //printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));

    //std::vector<Graph> &gg = g.getGraphs();
    //c.changeGraphColor(w.getWindows(), g.getGraphs()[0]);
    //c.changeGraphColor(w.getWindows(), g.getGraphs()[0]);
    //c.changeGraphColor(w.getWindows(), g.getGraphs()[2]);
    c.initial_total_color_diff(&g, g.getGraphs(), w.getWindows());
    //c.printResult(s.getShapes(), g.getGraphs(), w.getWindows(), argc, argv);
    //printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));

    for (int group_id = 0; group_id < c.group_size; group_id++) {
        c.iterative_sol(g.getGraphs(), w.getWindows(), group_id);
    }
    //printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));
    c.simulatedAnnealing(g.getGraphs(), w.getWindows(), start, argv[1]);

    for (int group_id = 0; group_id < c.group_size; group_id++) {
        c.iterative_sol(g.getGraphs(), w.getWindows(), group_id);
    }

    c.printResult(s.getShapes(), g.getGraphs(), w.getWindows(), argc, argv);
    printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));
    return 0;
}
Esempio n. 11
0
void Circle::on_pushButton_clicked() {
    Calculate* w = new Calculate;
    w->setAttribute(Qt::WA_DeleteOnClose);
    w->show();
    this->close();
}
Esempio n. 12
0
int main()
{
    Calculate my;
    my.calculate();
    return 0;
}
Esempio n. 13
0
//
// メインプログラム
//
int main()
{
  // GLFW を初期化する
  if (glfwInit() == GL_FALSE)
  {
    // GLFW の初期化に失敗した
    MessageBox(NULL, TEXT("GLFW の初期化に失敗しました。"), TEXT("すまんのう"), MB_OK);
    return EXIT_FAILURE;
  }

  // プログラム終了時には GLFW を終了する
  atexit(glfwTerminate);

  // OpenGL Version 3.2 Core Profile を選択する
  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

  // ウィンドウを開く
  Window window(640, 480, "Depth Map Viewer");
  if (!window.get())
  {
    // ウィンドウが作成できなかった
    MessageBox(NULL, TEXT("GLFW のウィンドウが開けませんでした。"), TEXT("すまんのう"), MB_OK);
    return EXIT_FAILURE;
  }

  // 深度センサを有効にする
  KinectV1 sensor;
  if (sensor.getActivated() == 0)
  {
    // センサが使えなかった
    MessageBox(NULL, TEXT("深度センサを有効にできませんでした。"), TEXT("すまんのう"), MB_OK);
    return EXIT_FAILURE;
  }

  // 深度センサの解像度
  int width, height;
  sensor.getDepthResolution(&width, &height);

  // 描画に使うメッシュ
  const Mesh mesh(width, height, sensor.getCoordBuffer());

  // 描画用のシェーダ
  GgSimpleShader simple("simple.vert", "simple.frag");

  // デプスデータから頂点位置を計算するシェーダ
  const Calculate position(width, height, "position.frag");

  // 頂点位置から法線ベクトルを計算するシェーダ
  const Calculate normal(width, height, "normal.frag");

  // 背景色を設定する
  glClearColor(background[0], background[1], background[2], background[3]);

  // 隠面消去処理を有効にする
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);

  // ウィンドウが開いている間くり返し描画する
  while (!window.shouldClose())
  {
#if GENERATE_POSITION
    // 頂点位置の計算
    position.use();
    glUniform1i(0, 0);
    glActiveTexture(GL_TEXTURE0);
    sensor.getDepth();
    const std::vector<GLuint> &positionTexture(position.calculate());

    // 法線ベクトルの計算
    normal.use();
    glUniform1i(0, 0);
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, positionTexture[0]);
    const std::vector<GLuint> &normalTexture(normal.calculate());
#else
    // 法線ベクトルの計算
    normal.use();
    glUniform1i(0, 0);
    glActiveTexture(GL_TEXTURE0);
    sensor.getPoint();
    const std::vector<GLuint> &normalTexture(normal.calculate());
#endif

    // 画面消去
    window.clear();

    // 描画用のシェーダプログラムの使用開始
    simple.use();
    simple.loadMatrix(window.getMp(), window.getMw());
    simple.setLight(light);
    simple.setMaterial(material);

    // テクスチャ
#if GENERATE_POSITION
    glUniform1i(0, 0);
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, positionTexture[0]);
#endif
    glUniform1i(1, 1);
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, normalTexture[0]);
    glUniform1i(2, 2);
    glActiveTexture(GL_TEXTURE2);
    sensor.getColor();

    // 図形描画
    mesh.draw();

    // バッファを入れ替える
    window.swapBuffers();
  }
}
Esempio n. 14
0
void Rectangle::on_bBack_clicked() {
    Calculate* w = new Calculate;
    w->setAttribute(Qt::WA_DeleteOnClose);
    w->show();
    this->close();
}