計算をプログラミングで

旅人算

距離49キロ間で

A 時速3キロ

B 時速4キロ

で移動。

A+Bの合計移動速度は7キロ

距離は49キロ。

 

よって、時間は7時間。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string args)
        {
            int kyori = 49;
            int A = 3;
            int B = 4;

            int OneTime = A + B;

            int TotalTime = kyori / OneTime;

            Console.WriteLine(TotalTime);
        }
    }
}

jukensansuu.com

 

ウサギとカメがレースをします。スタートと同時にカメは分速20mで走り始めましたが、ウサギは一眠りして、36分後に分速100mで走り出しました。 ウサギがカメに追いつくのは、ウサギがスタートしてから何分後でしょう。

int a = 亀の値

int b = 兎の値

 

int c = 亀のリードタイム (距離)

 

int d = 亀のリードタイム /(兎の速度)

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string args)
        {
            int a = 20;
            int b = 100;

            int c = 20 * 36;

            int d = c / (b - a);

            Console.WriteLine(d);
        }
    }
}