blue star. 10 發表於 September 27, 2008 檢舉 Share 發表於 September 27, 2008 我是C的新手對C還是十分陌生老師要我們寫一個猜數字的程式(我是用Dev-C++)我把老師給的程式打了上去有錯物但我找不到想麻煩C的高手幫我一下(畫//是要在加的程式使它能重複玩)#include <cstdlib>#include <iostream>#include<stdlib.h> using namespace std;int main(int argc, char *argv[]){ int answer,guess,count=0; bool g=false;// answer=rand()%1000+1; while(!g){ count++; count<<"Guess a number between 1~1000"<<endl; cin>>guess; if(guess>answer) cout<<"Too large!"<<endl; else if(guess<answer) cout<<"Too small!"<<count<<"times"<<endl; else { cout<<"Congrulation!"<<count<<"times"<<endl; g=true } }// system("PAUSE"); return EXIT_SUCCESS;} 鏈接文章 分享到其他網站
john0312 10 發表於 October 6, 2008 檢舉 Share 發表於 October 6, 2008 粗體部分語法錯誤,已更改.#include <cstdlib>#include <iostream>#include<stdlib.h> using namespace std;int main(int argc, char *argv[]){ int answer,guess,count=0; bool g=false; // answer=rand()%1000+1; while(!g){ count++; [B][U]cout[/U][/B]<<"Guess a number between 1~1000"<<endl; cin>>guess; if(guess>answer) cout<<"Too large!"<<endl; else if(guess<answer) cout<<"Too small!"<<count<<"times"<<endl; else { cout<<"Congrulation!"<<count<<"times"<<endl; g=true[U][B];[/B][/U] } } // system("PAUSE"); return EXIT_SUCCESS;} 鏈接文章 分享到其他網站
Recommended Posts
請登入後來留意見
在登入之後,您才能留意見
立即登入