•練習問題/解答例/ひらがな2文字をランダムで出力するプログラム/C
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[練習問題/解答例/ひらがな2文字をランダムで出力するプログ...
#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; }
終了行:
[[練習問題/解答例/ひらがな2文字をランダムで出力するプログ...
#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; }
ページ名: