diff --git a/esercitazioni/a.out b/esercitazioni/a.out index 56fe95d..a1653d3 100755 Binary files a/esercitazioni/a.out and b/esercitazioni/a.out differ diff --git a/esercitazioni/download_from_server.cpp b/esercitazioni/download_from_server.cpp index 9d2beff..b494519 100644 --- a/esercitazioni/download_from_server.cpp +++ b/esercitazioni/download_from_server.cpp @@ -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; }