如果你是HR 你会要我吗?

poppoo1986 2010-04-12 05:35:31
花了1天构思+编写 2天调试,最终都出问题的程序。
如果你是HR 你会要我这个菜鸟吗?

//CCreateNumber.cpp

#include <iostream>
#include <string>
#include <stdlib>
#include <ctime>



using namespace std;

#include "CCreateNumber.h"


//构造函数

//产生不重位随机数。
void CCreateNumber::RandomNumber()
{
int j,k;
do {
for(k=0;k<=3;k++)
{
srand((int)time(0)+(k+1)*11);
j=rand()%10;
this->a[k]=j;
}
} while (a[0]==a[1]||a[0]==a[2]||a[0]==a[3]||a[1]==a[2]||a[1]==a[3]||a[2]==a[3]);
this->RightNum=a[0]*1000+a[1]*100+a[2]*10+a[3];
}

//运行
void CCreateNumber::run()
{
int yourNumber;
do
{
cout<<"Enter the Number you guessed:"<<endl;
yourNumber=cin.get();
}
while(CCreateNumber::CompareNumber(yourNumber));
char chCommand;
void ShowMenu();
cout<<"Enter a command >\n\n";
chCommand=cin.get();
switch (chCommand)
{
case 'A':
cout<<"-----"<<this->RightNum<<"------"<<endl;
break;
case 'R':
void ReplayGame();
break;
case 'Q':
CCreateNumber::QuitGame();
break;
case 'D':
cout<<"1A代表所猜数字中有一个位置和答案一样,2A则代表两个。\n"
"1B代表所猜数字中有一个是答案中的数字但是位置不对。\n";
default:
cout<<"-------Wrong command--------"<<endl;
break;
}

}

//显示命令目录
void CCreateNumber::ShowMenu()
{
cout<<"Game commands are:\n"
"A : Show answer\n"
"R : Replay the game\n"
"Q : Quit game\n"
"D : Description\n";
}

const void ReplayGame()
{
PlayTimes++;
}

void CCreateNumber::QuitGame()
{
exit(0);
}

//对输入的数字进行反馈
void CCreateNumber::FeedBackNum(int x)
{
int b[4];
int p=0;
int q=0;
int i,j;
b[0]=x/1000;
b[1]=(x-x/1000*1000)/100;
b[2]=(x-x/100*100)/10;
b[3]=(x-x/10*10);
for(i=0;i<=3;i++)
{
if(this->a[i]=b[i])
p++;
for(j=0;j<=3;j++)
{
if(this->a[i]=b[j])
q++;
}
}
q=q-p;
cout<<"-----------"<<p<<"A"<<q<<"B"<<endl;
}


//比较两数字
bool CCreateNumber::CompareNumber(int a)
{
if (a==this->RightNum)
{cout<<"--------Congratulations!------"<<endl;
return true;}
else
{CCreateNumber::FeedBackNum(a);
return false;}
}







//td_mainApp.cpp
#include <iostream>
#include <string>
#include <time.h>
#include <stdlib.h>

using namespace std;

#include "CCreateNumber.h"



int main()
{
cout<<"--------- Welcome Game! ----------"<<endl;
CCreateNumber NewNumber[20];
if (PlayTimes>20)
{NewNumber[PlayTimes].run();}
else
{cout<<"----ALL Game Over!----"<<endl;}
return 0;
}










//CCreateNumber.h
#include <iostream>
#include <string>
using namespace std;


#ifndef CCreateNumber_H
#define CCreateNumber_H

static int PlayTimes=0;
class CCreateNumber
{
public:
CCreateNumber(){};


public:
void RandomNumber();
bool CompareNumber(int x);
void run();
void FeedBackNum(int x);
void ShowMenu();
void QuitGame();
private:
int a[4];
int RightNum;
};
#endif
...全文
215 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
nicholas05 2010-04-13
  • 打赏
  • 举报
回复
..................
poppoo1986 2010-04-13
  • 打赏
  • 举报
回复
郁闷+崩溃中!
poppoo1986 2010-04-13
  • 打赏
  • 举报
回复
其实现在又学习到很多东西,有时间就修改出来再放上来。
结贴了!
  • 打赏
  • 举报
回复
HR不会鸟你技术,技术有开发人员来面。
rendao0563 2010-04-13
  • 打赏
  • 举报
回复
还凑合至少会写代码。虽然问题很多。
glorier 2010-04-13
  • 打赏
  • 举报
回复
这要看出的是什么问题了
ylke2007 2010-04-13
  • 打赏
  • 举报
回复
有 #include <stdlib.h>和 #include <cstdlib>,没有 #include <stdlib> 吧。
不知是不是我搞错了。。。
  • 打赏
  • 举报
回复
看着头痛
贪食蛇男 2010-04-12
  • 打赏
  • 举报
回复
不要
回复内容太短了!
bullbat 2010-04-12
  • 打赏
  • 举报
回复
好长~~
FingerStyle 2010-04-12
  • 打赏
  • 举报
回复
晕了不忘接分。。
tan870426 2010-04-12
  • 打赏
  • 举报
回复
的确很晕!
poppoo1986 2010-04-12
  • 打赏
  • 举报
回复
是一个猜数游戏,就是一个不重复的4位数,用户猜,位置和数都对得上,就返回一个A 如果数字对 位置不对 就返回一个 B, 比如2A1B就是说 4个数字 你对了3个,其中2个位置都对,一个位置不对(例如 需要猜的数 1234 你猜的 1245 那就返回2A1B)
  • 打赏
  • 举报
回复
看着比较晕

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧