Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
add break point to download_from_server.cpp excercise
Browse files Browse the repository at this point in the history
  • Loading branch information
mc-cat-tty committed Oct 7, 2021
1 parent f1ff5ad commit 5ab2073
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Binary file modified esercitazioni/a.out
Binary file not shown.
23 changes: 13 additions & 10 deletions esercitazioni/download_from_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,33 @@ using namespace std;

int main() {
// [kb/s]
const int T1_MAX = 60*60,// seconds
V1_MAX = 200, // if t <= 60 min
const int V1_MAX = 200, // if t <= 60 min
V1_MIN = 50, // if t > 60 min
V2 = 100; // always
const int V1_MAX_TIME_SECONDS = 60*60;
int dim; // dimensione film [kb]

const int SECS_FOR_MIN = 60;
int dim, // dimensione film [kb]
server_index,
tempo_sec;

cout << "Dimensione film [kb]: ";
cin >> dim;

int t_v1_max = dim/V1_MAX; // seconds
if (t_v1_max <= T1_MAX)
cout << "Server 1 in " << t_v1_max/60;
if (t_v1_max <= V1_MAX_TIME_SECONDS)
{server_index = 1; tempo_sec = t_v1_max;}
else {
int max_dim_v1_max = V1_MAX*V1_MAX_TIME_SECONDS;
int dim_v1_min = dim-max_dim_v1_max;
int t_v1_min = dim_v1_min/V1_MIN;
int t_v2 = dim/V2;
// cout << t_v1_min;
if (V1_MAX_TIME_SECONDS+t_v1_min <= t_v2)
cout << "Server 1 in " << (V1_MAX_TIME_SECONDS+t_v1_min)/60;
{server_index = 1; tempo_sec = V1_MAX_TIME_SECONDS+t_v1_min;}
else
cout << "Server 2 in " << t_v2/60;
{server_index = 2; tempo_sec = t_v2;}
}
cout << " minutes" << endl;

cout << "Server " << server_index << " in " << tempo_sec/SECS_FOR_MIN << " minutes" << endl;
// break point is 1080000 bytes (when t is equal to 10800 seconds)
return 0;
}

0 comments on commit 5ab2073

Please sign in to comment.