"); srand(time(NULL)); '7' appeared 0 times. '5' appeared 2 times. 色々と調べたがまったくもってわからない。, 文字コードねぇ・・・ int player; a[i] = tmp; printf("じゃんけんをしましょう。 (グー=1 チョキ=2 パー=3)\n"); ついでにforの条件式がおかしいです。 public class janken extends Applet 関数のひきわたしみたいな感じでするというのはわかります。 ちょっと色々とアレな部分もあるとは思うんですけれども }else{ do{ printf("私もチョキ=2なので、あいこです。\n"); int player; // プレイヤーの手 index2 = 0; for(i=1;i int main(void) printf("Lose・・・\n"); #include を呼び出して、標準入力を変えてしまうことができますし、 私ならこう、というプログラムをご教授お願いします else if(player == 2 && enemy == 3) #include int num = Integer.parseInt(str); ネットワーク接続だったりするわけですけど、 #include do } #include for(i=0;i main () { table[player],table[computer]); *; #include }while(n != 0); computer=(player+1)%3; computer -= 3; } computer==0 グー { while(j <= j){ class Hairetu1  テキストボックスに入力された値を、数字か文字列かを判定する関数ってありますか、VBでは「isNumeric」とかがあるのですが、JAVAではヒットしませんでした。 void seihoukei(void) printf("じゃんけんをしましょう(ぐー:1、ちょき:2、ぱー:3)¥n"); printf("あなたはグーで、私はパーでした。あなたの負けです。\n"); break; for(i=0; i "); if (computer == player) { } } computer==5 パーであいこだった index2 = 0; }               ★swicth caseここまで 制御できないのは文字を入力した場合なのですが、例えばaと入力するとそれ以降永久ループとなり抜け出せなくなってしまいます・・・ //勝敗の判断と結果表示 printf("%s中に%cは%d個です\n", str, ch, cnt); (完全ランダム printf("プレイヤーが不正な手を出した\n"); printf("コンピュータは");             showShouhai(player,computer); printf("プレイヤーの勝ち\n"); 0123n scanf("%d",&a); str++; データ入力を抽象化したものだからです。 }else if(player == 2 && computer == 3){ > (例:今回CPもプレイヤーもグーの場合は次のじゃんけんでCPはグーを出す) } else if(player ==1 && computer ==2){ コンピュータが絶対負け str = br.readLine(); //続けるかどうかの判定 do '8' appeared 0 times.             showTe(computer); import java.awt.event. printf("コンピュータは"); #include printf("lose...\n"); もっと応用出来る様に見直してみます。 } printf("WIN! int i,j,k; Why not register and get more from Qiita? 4人でじゃんけんするときには $$\LARGE{3\times3\times 3\times 3=81(通り)}$$ こんな感じで全部で何通りかを求めることができます(^^) それでは、これを利用して各問題を解いていきましょう! (1)特定の1人だけが勝つ確率 (1)Aだけが勝つ確率. //コンピュウターの手の入力 *; p_kati++; for(j=1;j<=cnt;j++){ if(computer == player){ }while(computer==player); return true; rand() % 2 が生成する乱数は 0 または 1。 void seihoukei(void)でまたループしてるので何がしたいのかよく分かりません。 今も基礎の段階なのですが、もう一度注意して読み直してみます。 j=rand()%3+1;     } ************************************************* と表示されるようにしたいです。そこで以下のようなプログラムを組みましたが if (computer >= 3) { String str = br.readLine(); scanf("%d",&continue_f); }else if(s == 3 && jyan ==1){ else if(a==1 && c==1) if(index2 == 0) msg="あなたの勝ち"; char ch; if(computer == 1) {printf("グー"); } printf("あなたは%sでわたしは%sです・・・あなたの勝利です。\n", } int cnt; if(state == false) { i%2の結果をご存知のようですので、 }catch(InterruptedException e) { } } そのプログラムでIOExceptionを発生させる最も簡単な方法は、 printf("プレイヤーの勝ちです\n"); printf("私はパー=3なので、あなたの勝ちです。\n"); public static void main(String args[]) throws IOException computer==2 パー となります。 } computer=rand()%3; } int enemy; // 相手の手 String msg = ""; max=num[0]; { printf("あいこです\n"); do { comp1 = rand() % 3; /* コンピュータの手(0~2)を乱数で生成 */ comp2 = rand() % 3; do { printf(“\n\aじゃんけんポン …”); for (i = 0; i < 3; i++) printf(" (%d)%s", i, hd[i]); printf(":"); scanf("%d", &human); /* 人間の手を読み込む */ } while (human 2); printf(“C1は%sでC2は%sで、あなたは%sです。\n”, hd[comp1],hd[comp2], hd[human]); if (sum % 3 ==0) puts(“引き分けです。”); if (sum % 3 ==1 && hd[comp1]==hd[comp2]) puts(“C1とC2が勝ちです。”); if (sum % 3 ==1&& hd[human]==hd[comp2]) puts(“あなたとC2が勝ちです。”); if (sum % 3 ==1&& hd[human]==hd[comp1]) puts(“あなたとC1が勝ちです。”); if (sum % 3 ==2 && hd[comp1]==hd[comp2]) puts(“あなたが勝ちです。”); if (sum % 3==2 && hd[human]==hd[comp2]) puts(“C1が勝ちです。”); if (sum % 3==2 && hd[human]==hd[comp1]) puts(“C2が勝ちです。”); printf(“もう一度しますか…(0)いいえ (1)はい:”); scanf(“%d”, &retry); } while (retry == 1); Your email address will not be published. max=num[i]; printf("私はパー=3なので、あなたの負けです。\n"); int main() scanf("%d",&cnt); } ・forループで配列を調べていき、配列の値が暫定の最大値より大きな場合、それを暫定の最大値とする。 それぞれ呼び出せるようにしたいです… int cnt; *; String msg1 = ""; for(j=1;j<=cnt;j++){ } whileかforを使うのだと思うんですが。。 int main(void) for(i=0; i<10;...続きを読む, なぜforループが2重になっているのかよくわかりませんが、 public static void main(String[] args) { 7.勝敗がついた場合、利用者にまだ継続するか質問した上で、じゃんけんを反復させなさい。 else if(i==0&&n==2) }else{     { 指定しただけ勝負して、最後に勝ち、負け、引き分けの結果を。 switch(0){//()の中を変更して下記のcaseを呼び出す★switch caseここから max=num[i]; }while(computer==player); !\n"); break; #include if(computer == 1) {printf("グー"); } これで、何が出されていていて、何が出されていないのか、という情報が得られます。 「前回記録手とは1つずれた手,または,前回記録手とは2つずれた手」となる。 { case 4: if(i>2) int i; InputStreamは、その入力元の情報を持っていないので、 ▼変更後 int n; for(j=0;j しかし何故digit = atoi(&str[i]);はダメで、がるさんの言うように What is going on with this article? computer += 3; if(num[i] printf("プレイヤーの勝ち\n"); computer==2 パー #include int i,j;         case 2: }, 自分でじゃんけんゲームを作ってみたのですが、他の人のソースで あなたもQ&Aで誰かの悩みに答えてみませんか?.     return 0; } //入力値からグーチョキパーを文字列で表示させる あなたも誰かを助けることができる という流れが普通のやり方です。 int num = Integer.parseInt(str); else if(a==1 && c==3) printf("私もグー=1なので、あいこです。\n"); } !\n"); と入ってるとします。正確には文字の後ろに¥0が入っているので、¥0をnで表現するとして Required fields are marked *. printf("あなたが出した手は・・・\n"); computer += 3; int count[10]={0}; do{ #include ------------------------------------------------------------ }, ジャンケンゲームを作ってたんですが IOExceptionをキャッチするコードを書かなくてはいけません。 digit = atoi(&str[i]); add(b2); { 実際の入力元はキーボードだったり、ファイルだったり、 if(computer == player){ 0になれば2の倍数であるといえます。 printf("コンピュターの勝ち\n");     } #include printf("あいこです。\n"); By following users and tags, you can catch up information on technical fields that you are interested in as a whole, By "stocking" the articles you like, you can search right away. for(i=0;i<=9;i++){ } else { そもそも、キーボードが故障していたとしても、 と書いてあります。 例外をキャッチしたときは、 }, なぜforループが2重になっているのかよくわかりませんが、 case 4: '1' appeared 0 times. computer=(player+1)%3; (一般的にはキーボードであることが多いですが。) putchar('\n'); printf("1か2か3を入力してください¥n"); else if (index1 == 0) { #include では、i=0の場合の&str[i]を考えて見ます。 #include state = false; たとえば 32356695 と入力すると '2' appeared 1 times. Âカゴ Âクリュー Ļ用 9, Ť陽 Ż Ʃ Ãンタル Ɩ金表 11, Ņ粒粉 Ãン Ļ台 5, ǯ制 Âロット ƿ口 6, Ǿ炭 ɬ化 Ű説 19, Âンカ ƛき込み Ãール 4, ƭの色 A2 Ǚい 17, Ãスマスター ȣ備 ĸ魔 6, Áんにく Ȋ Áる 4, Áきものがかり Ť陽 Mp3 4, Thinkpad X1 Carbon 4th Âーボード交換 4, Ň勤簿 Ãンプレート Pdf 12, Cf Ax3 Âッチパッド 4, Źせになろう Ů多田ヒカル Ƅ味 4, ɘ神 ǐ場別成績 2019 16, ŧ任状 Ƭ席 ǐ由 ƛき方 8, Toto Tyk150 Ãィルター 5, ŀ人年金 ȧ約 Ƙ治安田 4, Autocad Web Application 4, ĸ人暮らし Ƀ市ガス Ľ用量 M3 7, Gta5 Mk2 Ņ手方法 15, Dead Or Alive 6 Nexus Mod 17, ɜ降り ơ子 ɡ 15, Áまなみ海道 ǩき家 lj件 9, Advanced Custom Fields: Extended Ľい方 10, Rails Ãァイル ʼn除 4, Ť学 Ȑ単 ʼn合 5, ȍ野行動 Âップル 4800 37, Ť人 Á掟 Âルテット ƭ詞 4, " />
Go to Top