ランダムで予想
競馬の着順を簡単なプログラムでランダムに予想してみようかなと思いました。こんな感じです↓↓コードはこれだけ(C言語)#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <time.h>int main(void){ int horse, one, two, three; srand((unsigned)time(NULL)); printf("出走馬の頭数を入力:"); scanf("%d", &horse); system("cls"); one = rand() % horse + 1; two = one; while (one == two) { two = rand() % horse + 1; } three = one; while (one == three || two == three) { three = rand() % horse + 1; } printf("1着:%d番\n", one); printf("2着:%d番\n", two); printf("3着:%d番\n", three); horse = getch(); return 0;}