Archived
Работы по программированию
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include <iostream>
|
||||
#include <graphics.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int gd = DETECT, gm;
|
||||
initgraph(&gd, &gm, "");
|
||||
|
||||
const double distance = 208;
|
||||
const double riverSpeed = 5;
|
||||
const double timeDifference = 5;
|
||||
|
||||
double boatSpeed = (distance * (riverSpeed + distance / (timeDifference + distance / riverSpeed))) / (2 * distance);
|
||||
|
||||
int riverWidth = 50;
|
||||
line(50, 200, 50 + riverWidth, 200);
|
||||
line(50, 250, 50 + riverWidth, 250);
|
||||
line(50, 200, 50, 250);
|
||||
line(50 + riverWidth, 200, 50 + riverWidth, 250);
|
||||
|
||||
int boatSize = 20;
|
||||
int boatX = 50 + riverWidth / 2 - boatSize / 2;
|
||||
int boatY = 220;
|
||||
rectangle(boatX, boatY, boatX + boatSize, boatY + boatSize / 2);
|
||||
line(boatX + boatSize / 2, boatY + boatSize / 4, boatX + boatSize / 2 - 10, boatY + boatSize / 4 - 10);
|
||||
line(boatX + boatSize / 2, boatY + boatSize / 4, boatX + boatSize / 2 - 10, boatY + boatSize / 4 + 10);
|
||||
line(boatX + boatSize / 2, boatY + boatSize / 4, boatX + boatSize / 2 + 10, boatY + boatSize / 4 - 10);
|
||||
line(boatX + boatSize / 2, boatY + boatSize / 4, boatX + boatSize / 2 + 10, boatY + boatSize / 4 + 10);
|
||||
|
||||
char text[50];
|
||||
sprintf(text, "Boat speed: %.2f km/h", boatSpeed);
|
||||
outtextxy(10, 70, text);
|
||||
getch();
|
||||
closegraph();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user