יעול התוכנית
רציתי לדעת אם יש לכם דרך ליעל את התוכנית. בכלליות היא קולטת שעה של יציאה, ואת זמן הנסיעה, ומחשבת את שעת ההגעה
רציתי לדעת אם יש לכם דרך ליעל את התוכנית. בכלליות היא קולטת שעה של יציאה, ואת זמן הנסיעה, ומחשבת את שעת ההגעה
// This program reades time of departure (hours, minutes and seconds), and the // time of travelling (in seconds). // The program calucates the time of arrival (hours, minutes and seconds). // developer: Alon Kukliansky, Date: 24/9/2002 #include<iostream.h> void main() { long start_hour, start_min, start_sec, starttime_sec, timeoftravel_sec, temp; long end_hour, end_min, end_sec; cout <<"This program caculates the time of arrival. \n"; cout <<"Enter the time of departure (hour/minute/second), "; cout <<"and enter the travel time in seconds.\n"; // Reading the departure time cin >> start_hour >> start_min >> start_sec >> timeoftravel_sec; cout <<"If you will leave at "<<start_hour<<":"<<start_min<<":"<<start_sec; cout <<".\nAnd you will drive "<<timeoftravel_sec<<" seconds.\n"; // Calculatting the arrival time starttime_sec = start_hour * 3600 + start_min * 60 + start_sec; temp = timeoftravel_sec + starttime_sec; end_sec = temp % 60; end_hour = (temp / 3600); end_min = ((temp / 60) % 60); // Printing the arrival time cout <<"You will arrive at "<<end_hour<<":"<<end_min<<":"<<end_sec<<"."; }
זה