-3
年齢を秒単位で変換する際に問題があります。それは間違った番号と否定的な番号で始まります。誰かが助けてくれますか?年齢を日、時間、分、および秒で変換する
#include <iostream>
using namespace std;
int main()
{
int years;
years = years;
cout << "How many years have you lived: " ;
cin >> years;
cout << "You have lived: " << years; cout << " years:" << endl;
int days = 0.5 + (years * 365.25);
cout << days; cout << " days" << endl;
int hours = days * 24;
cout << hours; cout << " hours" << endl;
int minutes = hours * 60;
cout << minutes; cout << " minutes" << endl;
int seconds = minutes * 60;
cout << seconds; cout << " seconds" << endl;
return 0;
}
'年=年の行を削除することを忘れないでください、長い長い分と長い長い秒代わりのint型
とを使用する;'です自動保存期間を持つデフォルト初期化変数の不定値が使用されるため、無意味で危険です。それを除く。 – MikeCAT
この問題は、鎮静作用があふれている可能性があります。もっと正確な型を使ってみてください。 – MikeCAT
"間違った番号と否定的なものが出てくる"というのは、役に立つ問題の説明ではありません。 「こんにちは、マイクの自動修理?私の車は動かない、何か考えがあるの?」 –