[ create a new paste ] login | about

Link: http://codepad.org/C6lW8PaT    [ raw code | fork ]

C, pasted on Dec 27:
#include <stdio.h>

int table[5][5] =
{
    /* 東京発。*/
    {0, 3180, 11540, 14390, 14920},
    /* 新横浜発。*/
    {3180, 0, 10910, 13660, 14600},
    /* 名古屋発 */
    {11540, 10910, 0, 6100, 6840},
    /* 京都発 */
    {14390, 13660, 6100, 0, 3240},
    /* 新大阪発 */
    {14920, 14600, 6840, 3240, 0},
};

int main(void)
{
    int n, hatsu, chaku;

    for(;;)
    {
        printf("東京:1, 新横浜:2, 名古屋:3, 京都:4, 新大阪:5\n");
        printf("出発駅の駅番号: ");
        scanf("%d", &hatsu);
        printf("到着駅の駅番号: ");
        scanf("%d", &chaku);
        printf("料金は%d円です。", table[hatsu - 1][chaku - 1]);
        printf("繰り返しますか? (1:はい、0:いいえ) ");
        scanf("%d", &n);
        if (n == 0)
            break;
    }

    return 0;
}


Create a new paste based on this one


Comments: