練習問題/解答例/ひらがな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;
		j = rand() % 46;
		printf("%s%s", hrgn[i], hrgn[j]);	
		if (n % 10 == 0) printf("\n");
		else printf(" ");
		n++; }
	return; }

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS