program_10_4.cpp

来自「清华关于C++ 的程序讲义 值得一看 关于算法」· C++ 代码 · 共 41 行

CPP
41
字号
// Program to illustrate mechanics of API program
#include <iostream>
#include <string>
#include <cassert>
#include <ezwin>
using namespace std;

SimpleWindow HelloWindow("Hello EzWindows", 10., 4., Position(5., 6.));

//ApiMain(): demonstrate using cin with EzWindows
int ApiMain() {
	HelloWindow.Open();
	assert(HelloWindow.GetStatus() == WindowOpen);

	cout << "Enter the location in the window\n"
		<< "to write the text (e.g., 4 6): ";
	int XCoordinate;
	int YCoordinate;
	cin >> XCoordinate >> YCoordinate;

	Position Location(XCoordinate, YCoordinate);
	Position UpperLeft = Location+ Position(-1., -1.);
	Position LowerRight = Location+ Position(1., 1.);

	// Display the text
	HelloWindow.RenderText(UpperLeft, LowerRight, "Hello Ezwindows", Black);

	cout << "Text was rendered at " << XCoordinate
		<< ", " << YCoordinate << endl;
	
	return 0;
}

// ApiEnd(): shutdown the window
int ApiEnd() {
	HelloWindow.Close();

	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?