練習問題/解答例/ひらがな2文字をランダムで出力するプログラム/C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
	char *c;
	int i, j;
	int n = 1;
	char hrgn[46][4] = {
	    "あ","い","う","え","お","か","き","く","け","こ","さ","し","す","せ","そ",
	    "た","ち","つ","て","と","な","に","ぬ","ね","の","は","ひ","ふ","へ","ほ",
	    "ま","み","む","め","も","や","ゆ","よ","ら","り","る","れ","ろ","わ","を","ん" };
	
	srand(time(NULL));

	while (n <= 1000) {
		i = rand() % 45;        // 1文字目に『ん』が来ないように
		j = rand() % 46;
		printf("%s%s", hrgn[i], hrgn[j]);	
		if (n % 10 == 0) printf("\n");
		else printf(" ");
		n++; }
	return; }

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-02-23 (木) 23:33:35