標題:
[作業] 時間換算機 (二)
[打印本頁]
作者:
方浩葦
時間:
2024-7-6 12:05
標題:
[作業] 時間換算機 (二)
將輸入的
秒數
, 換算成
幾週, 幾天, 幾小時, 幾分鐘, 幾秒
.
本帖隱藏的內容需要回復才可以瀏覽
作者:
劉奕劭
時間:
2024-7-6 15:31
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int x;
re:
cout<<"請輸入你想換算的秒數";
cin>>x;
cout<<"可換算為";
if(x<=0){
goto re;
}
if(x>=604800){
cout<<x/604800<<"週"<<endl;
x%=604800;}
if(x>=86400){
cout<<x/86400<<"週"<<endl;
x%=86400;}
if(x>=3600){
cout<<x/3600<<"小時"<<endl;
x%=3600;}
if(x>=60){
cout<<x/60<<"分鐘"<<endl;
x%=60;}
if(x>=1){
cout<<x/1<<"秒"<<endl;
x%=1;}
system("pause");
return 0;
}
複製代碼
作者:
高湘庭
時間:
2024-7-6 15:54
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int x;
re:
cout<<"請輸入你想換算的秒數";
cin>>x;
cout<<x<<"秒可換算為";
if(x>60*60*24*7){
cout<<x/60/60/24/7<<"週"<<endl;
x%=60*60*24*7;
}
if(x<60*60*24*7&&x>=60*60*24){
cout<<x/60/60/24<<"天"<<endl;
x%=60*60*24;
}
if(x>=60*60&&x<60*60*24){
cout<<x/60/60<<"小時"<<endl;
x%=60*60;
}
if(x>=60&&x<60*60){
cout<<x/60<<"分鐘"<<endl;
x%=60;
}
if(x<60&&x>0){
cout<<x<<"秒"<<endl;
}
goto re;
system("pause");
return 0;
}
複製代碼
作者:
李唯銘
時間:
2024-7-6 16:16
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
system("cls");
int a;
cout<<"輸入想換算的秒數"<<endl;
cin>>a;
if(a>60*60*24*7){
cout<<a/60/60/24/7<<"週"<<endl;
a%=60*60*24*7;
}
if(a>60*60*24){
cout<<a/60/60/24<<"天"<<endl;
a%=60*60*24;
}
if(a>60*60){
cout<<a/60/60<<"小時"<<endl;
a%=60*60;
}
if(a>60){
cout<<a/60<<"分"<<endl;
a%=60;
}
if(a>0){
cout<<a<<"秒"<<endl;
}
cout<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
作者:
林少謙
時間:
2024-7-13 14:50
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int x;
cout<<"請輸入你想換算的秒數:";
cin>>x;
cout<<x<<"秒可換算為......"<<endl;
if(x>=604800)
{
cout<<x/604800<<"週,";
x=x%604800;
}
if(x>=86400)
{
cout<<x/86400<<"天,";
x=x%86400;
}
if(x>=3600)
{
cout<<x/3600<<"小時,";
x=x%3600;
}
if(x>=60)
{
cout<<x/60<<"分鐘,";
x=x%60;
}
if(x>0)
{
cout<<x<<"秒";
}
system("pause");
return 0;
}
複製代碼
作者:
洪榮辰
時間:
2024-7-13 15:55
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
re:
int time;
cout<<"請輸入你想換算的秒數: ";
cin>>time;
cout<<time<<"秒可換算為..."<<endl;
{
if(time>=604800)
{cout<<time/604800<<"週, ";
time%=604800;}
if(time>=86400)
{cout<<time/86400<<"天, ";
time%=8640;}
if(time>=3600)
{cout<<time/3600<<"小時, ";
time%=3600;}
if(time>=60)
{cout<<time/60<<"分鐘, ";
time%=60;}
if(time>=1)
{cout<<time/1<<"秒.";
time%=1;}
}
cout<<endl;
goto re;
system("pause");
return 0;
}
複製代碼
作者:
陳妍蓁
時間:
2024-7-18 21:57
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
int x;
cout<<"請輸入你要換算的秒數:"<<endl;
cin>>x;
cout<<x<<"秒可以換算成: ";
if(x>=604800){
cout<<x/604800<<"周 ";
x=x%604800;
}
if(x>=86400){
cout<<x/86400<<"天 ";
x=x%86400;
}
if(x>=3600){
cout<<x/3600<<"小時 ";
x=x%3600;
}
if(x>=60){
cout<<x/60<<"分鐘 ";
x=x%60;
}
if(x>=1){
cout<<x<<"秒";
}
cout<<endl;
system("pause");
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2