#include <string.h>
#include <fstream>
#include <vector>
#include <cstdlib>
#include "e:/c++2/test.h"
using namespace std;
test::test() {
int num_tries=0;
int num_right=0;
float usr_score=0.0;
vector<int>fibonacci(seq_size),sequence1(seq_size),sequence2(seq_size),sequence3(seq_size);
fibonacci[0]=1;
fibonacci[1]=1;
for(int ix=2;ix<seq_size;++ix)
fibonacci[ix]=fibonacci[ix-1]+fibonacci[ix-2];
sequence1[0]=3;
for(int iy=1;iy<seq_size;++iy)
sequence1[iy]=sequence1[iy-1]*4;
sequence2[0]=6;
for(int iz=1;iz<seq_size;++iz)
sequence2[iz]=sequence2[iz-1]+6;
sequence3[0]=1;
sequence3[1]=1;
sequence3[2]=1;
for(int ih=3;ih<seq_size;++ih)
sequence3[ih]=sequence3[ih-1]+sequence3[ih-2]+sequence3[ih-3];
vector<int> *seq_addrs[seq_cnt]={
&fibonacci,&sequence1,&sequence2,&sequence3};
vector<int> *current_addrs;
usr_more=true;
next_sg=true;
enum{max_tries=5};
}
test::~test() {cout<<"test is ending"<<endl;}
test::panduan() {
while(next_sg==true)
{
srand(4);
int seq_index=rand()%4;
current_addrs=seq_addrs[seq_index];
cout<<"The first is"<<current_addrs[0]<<endl;
cout<<"The second is"<<current_addrs[1]<<endl;
cout<<"The third is:"<<endl;
cin>>usr_val;
while(usr_val==current_addrs[2])
{
num_tries++;
num_right++;
usr_score++;
cout<<"OK!You are right!"<<endl;
}
num_tries++;
cout<<"Sorry!You are wrong!"<<endl;
cout<<"Are you try again?"<<endl;
cin>>usr_rsp;
if(usr_rsp=='n'||usr_rsp=='N')
{next_sg=false;
cout<<"Bye!"<<endl;}
else next_sg=true;
}
}
2 个解决方案
#1
有什么出错信息吗?
#2
#include <string.h>
#include <fstream>
#include <vector>
#include <stdlib.h> //这么用把<cstdlib>实际上还是调用的stdlib.h文件
#include "e:/c++2/test.h"
using namespace std;
#include <fstream>
#include <vector>
#include <stdlib.h> //这么用把<cstdlib>实际上还是调用的stdlib.h文件
#include "e:/c++2/test.h"
using namespace std;
#1
有什么出错信息吗?
#2
#include <string.h>
#include <fstream>
#include <vector>
#include <stdlib.h> //这么用把<cstdlib>实际上还是调用的stdlib.h文件
#include "e:/c++2/test.h"
using namespace std;
#include <fstream>
#include <vector>
#include <stdlib.h> //这么用把<cstdlib>实际上还是调用的stdlib.h文件
#include "e:/c++2/test.h"
using namespace std;