1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <conio.h>
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int sum(int x, int y);
void cls(HANDLE hConsole);
int main()
{
; getx:
; printf("Calculate: ");
; string x_unconv = "";
; getline(cin, x_unconv);
; HANDLE hStdout;
; hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
; cls(hStdout);
; if (x_unconv == "") {goto getx;};
; int x = atoi(x_unconv.c_str());
; gety:
; printf("Calculate: %d + ", x);
; string y_unconv = "0";
; getline(cin, y_unconv);
; hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
; cls(hStdout);
; if (y_unconv == "") { goto gety;};
; int y = atoi(y_unconv.c_str());
; printf("Calculate: %d + %d = %d\n", x, y, sum(x, y));
; printf("Press any key to continue . . . ");
; _getch();
; return 0;
}
int sum(int x, int y)
{
; return x + y;
}
void cls(HANDLE hConsole)
{
; COORD coordScreen = { 0, 0 };
; DWORD cCharsWritten;
; CONSOLE_SCREEN_BUFFER_INFO csbi;
; DWORD dwConSize;
; if (!GetConsoleScreenBufferInfo(hConsole, &csbi)) { return; };
; dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
; if (!FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten)) { return; };
; if (!GetConsoleScreenBufferInfo(hConsole, &csbi)) { return; };
; if (!FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten)) { return; };
; SetConsoleCursorPosition(hConsole, coordScreen);
}
|