Archived
Работы по программированию
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include <iostream>
|
||||
#include <graphics.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int gd = DETECT, gm;
|
||||
initgraph(&gd, &gm, "");
|
||||
|
||||
srand(time(0));
|
||||
ofstream fileX("x.txt"), fileY("y.txt");
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
int x = rand() % 31 - 5;
|
||||
int y = rand() % 31 - 5;
|
||||
fileX << x << endl;
|
||||
fileY << y << endl;
|
||||
}
|
||||
|
||||
fileX.close();
|
||||
fileY.close();
|
||||
|
||||
ifstream fileXRead("x.txt"), fileYRead("y.txt");
|
||||
int x, y;
|
||||
while (fileXRead >> x && fileYRead >> y) {
|
||||
int graphX = x * 10 + 100;
|
||||
int graphY = 400 - y * 10;
|
||||
|
||||
if (x + y == 35) {
|
||||
circle(graphX, graphY, 5);
|
||||
} else {
|
||||
putpixel(graphX, graphY, WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
fileXRead.close();
|
||||
fileYRead.close();
|
||||
|
||||
getch();
|
||||
closegraph();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user