これは私のプログラムのコードです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace YourGold
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to YourGold App! \n------------------------");
Console.WriteLine("Inesrt your gold: ");
int gold;
while (!int.TryParse(Console.ReadLine(), out gold))
{
Console.WriteLine("Please enter a valid number for gold.");
Console.WriteLine("Inesrt your gold: ");
}
Console.WriteLine("Inesrt your time(In Hours) played: ");
float hours;
while (!float.TryParse(Console.ReadLine(), out hours))
{
Console.WriteLine("Please enter a valid number for hours.");
Console.WriteLine("Inesrt your hours played: ");
}
float time = ((int)hours) * 60 + (hours % 1) * 100; ; // Here the calculation are wrong...
Console.WriteLine("Your total time playd is : " + time + " minutes");
float goldMin = gold / time;
Console.WriteLine("Your gold per minute is : " + goldMin);
Console.WriteLine("The application has ended, press any key to end this app. \nThank you for using it.\n but no thanks");
Console.ReadLine();
//Console.WriteLine(" \nApp self destruct!");
//Console.ReadLine();
}
}
}
ローカルの Visual Studio 環境を使用して実行しようとすると、自分のプログラムに時間を渡すときの出力minutes
が等しいことがコンソールに表示されます。900
1.5
これを で実行すると、出力が同じ値でwww.ideone.com
あることがわかります。90 minutes
1.5
コードのどこで間違いを犯す可能性がありますか? 異なる場所で実行すると、プログラムの動作が異なるのはなぜですか?