急!编译后:未声明的标识符

eniyi 2009-01-02 05:10:57
#include "iostream.h"
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include "stdafx.h"
#define Bsize 4
typedef struct BLOCK//声明一种新类型——物理块类型
{ int pagenum;//页号
int accessed;//访问字段,其值表示多久未被访问
}BLOCK;
int pc;//程序计数器,用来记录指令的序号
int n;//缺页计数器,用来记录缺页的次数
static int temp[320];//用来存储320条随机数
BLOCK block[Bsize]; //定义一大小为4的物理块数组
void init( ); //程序初始化函数
int findExist(int curpage);//查找物理块中是否有该页面
int findSpace( );//查找是否有空闲物理块
int findReplace( );//查找应予置换的页面
void display ( );//显示
void suijishu( );//产生320条随机数,显示并存储到temp[320]
void pagestring( );//显示调用的页面队列
void OPT( );//OPT算法
void LRU( );// LRU算法
void FIFO( );//FIFO算法
void init( )
{
for(int i=0;i<Bsize;i++)
{
block[i].pagenum=-1;
block[i].accessed=0;
pc=n=0;
}
}
int findExist(int curpage)
{
for(int i=0; i<Bsize; i++)
{
if(block[i].pagenum == curpage )
return i;//检测到内存中有该页面,返回block中的位置}
return -1;
}
}
int findSpace( )
{
for(int i=0; i<Bsize; i++)
{
if(block[i].pagenum == -1)
return i;//找到空闲的block,返回block中的位置}
} return -1;
}
int findReplace( )
{
int pos = 0;
for(int i=0; i<Bsize; i++)
{
if(block[i].accessed >block[pos].accessed)
pos = i;//找到应予置换页面,返回BLOCK中位置 }
return pos;
}
}
void display( )
{ for(int i=0; i<Bsize; i++)
{ if(block[i].pagenum != -1)
{
printf(" %02d",block[i].pagenum);
}
}
cout<<endl;
}
void suijishu( )
{
int flag=0;
cin>>pc;
cout<<"******按照要求产生的320个随机数:*******"<<endl;
for(int i=0;i<320;i++)
{
temp[i]=pc;
if(flag%2==0) pc=++pc%320;
if(flag==1) pc=rand( )% (pc-1);
if(flag==3) pc=pc+1+(rand( )%(320-(pc+1)));
flag=++flag%4;
printf(" %03d",temp[i]);
if((i+1)%10==0) cout<<endl;
}
}
void pagestring( )
{
for(int i=0;i<320;i++)
{
printf(" %02d",temp[i]/10);
if((i+1)%10==0) cout<<endl;
}
}
void OPT( )
{ int exist,space,position ;
int curpage;
for(int i=0;i<320;i++)
{ if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace ( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ for(int k=0;k<Bsize;k++)
{for(int j=i;j<320;j++)
{if(block[k].pagenum!= temp[j]/10)
{ block[k].accessed = 1000;
}//将来不会用,设置为一个很大数
else
{ block[k].accessed = j;
break;
}
}
}
position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
}
cout<<"缺页次数:"<<n<<endl;
cout<<"缺页率:"<<(n/320.0)*100<<"%"<<endl;
}
void LRU( )
{ int exist,space,position ;
int curpage;
for(int i=0;i<320;i++)
{ if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
else block[exist].accessed = -1;//恢复存在的并刚访问过的BLOCK中页面accessed为-1
for(int j=0; j<4; j++)
{
block[j].accessed++;
}
}
cout<<"缺页次数:"<<n<<endl;
cout<<"缺页率:"<<(n/320.0)*100<<"%"<<endl;
}
void FIFO( )
{
int exist,space,position ;
int curpage;
for(int i=0;i<320;i++)
{
if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
block[position].accessed--;
}
}
for(int j=0; j<Bsize; j++)
block[j].accessed++;}
cout<<"缺页次数:"<<n<<endl;
cout<<"缺页率:"<<(n/320.0)*100<<"%"<<endl;
}
void main( )
{
int select;
cout<<"请输入第一条指令号(0~320):";
suijishu( );
cout<<"*****对应的调用页面队列*******"<<endl;
pagestring( );
do
{ cout<<"****************************************"<<endl;
cout<<"------1:OPT 2:LRU 3:FIFO 4:退出-----"<<endl;
cout<<"****************************************"<<endl;
cout<<" 请选择一种页面置换算法:";
cin>>select;
cout<<"****************************************"<<endl;
init( );
switch(select)
{ case 1:cout<<"最佳置换算法OPT:"<<endl;
cout<<"*****************"<<endl;
OPT( );
break;
case 2:cout<<"最近最久未使用置换算法LRU:"<<endl;
cout<<"**************************"<<endl;
LRU( );
break;
case 3:cout<<"先进先出置换算法FIFO:"<<endl;
cout<<"*********************"<<endl;
FIFO( );
break;
default: ;
}
}while(select!=4);
}

编译后:
错误 1 error C2065: “cout”: 未声明的标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 69
错误 2 error C2065: “endl”: 未声明的标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 69
错误 3 error C2065: “cin”: 未声明的标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 74
错误 4 error C3861: “rand”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 80
错误 5 error C3861: “rand”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 81
错误 6 error C3861: “getch”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 99
错误 7 error C3861: “getch”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 136
错误 8 error C3861: “getch”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 169

怎么回事?
...全文
3006 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
yoursing 2012-09-22
  • 打赏
  • 举报
回复
1>.\zypoe.cpp(9) : error C2653: “std”: 不是类或命名空间名称
1>.\zypoe.cpp(9) : error C2065: “cout”: 未声明的标识符

要添加 这个
#include <iostream>
using namespace std;

要连在一起
zypoe 2012-03-14
  • 打赏
  • 举报
回复
请问这个怎么修改,如何声明,在什么文件下声明。请好心人指教,谢谢1>zypoe.cpp
1>.\zypoe.cpp(9) : error C2653: “std”: 不是类或命名空间名称
1>.\zypoe.cpp(9) : error C2065: “cout”: 未声明的标识符
无敌小猫猫 2011-09-19
  • 打赏
  • 举报
回复
#include <conio.h>
cunyan_0519 2011-08-08
  • 打赏
  • 举报
回复
代码太长了
toadzw 2009-01-02
  • 打赏
  • 举报
回复
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
//下面能通过?
//#include "stdafx.h"
//使用命名空间std
using namespace std;

#define Bsize 4
typedef struct BLOCK//声明一种新类型——物理块类型
{ int pagenum;//页号
int accessed;//访问字段,其值表示多久未被访问
}BLOCK;
int pc;//程序计数器,用来记录指令的序号
int n;//缺页计数器,用来记录缺页的次数
static int temp[320];//用来存储320条随机数
BLOCK block[Bsize]; //定义一大小为4的物理块数组
void init( ); //程序初始化函数
int findExist(int curpage);//查找物理块中是否有该页面
int findSpace( );//查找是否有空闲物理块
int findReplace( );//查找应予置换的页面
void display ( );//显示
void suijishu( );//产生320条随机数,显示并存储到temp[320]
void pagestring( );//显示调用的页面队列
void OPT( );//OPT算法
void LRU( );// LRU算法
void FIFO( );//FIFO算法

void init( )
{
for(int i=0;i <Bsize;i++)
{
block[i].pagenum=-1;
block[i].accessed=0;
pc=n=0;
}
}

//返回值有问题
int findExist(int curpage){
for(int i=0; i <Bsize; i++){
if(block[i].pagenum == curpage )
return i;//检测到内存中有该页面,返回block中的位置
}
//return -1放下面
return -1;
}

int findSpace( )
{
for(int i=0; i <Bsize; i++)
{
if(block[i].pagenum == -1)
return i;//找到空闲的block,返回block中的位置}
} return -1;
}
int findReplace( ){
int pos = 0;
for(int i=0; i <Bsize; i++){
if(block[i].accessed >block[pos].accessed)
pos = i;//找到应予置换页面,返回BLOCK中位置
return pos;
}
//这里需要返回值,没找到返回0
return 0;
}
void display( )
{ for(int i=0; i <Bsize; i++)
{ if(block[i].pagenum != -1)
{
printf(" %02d",block[i].pagenum);
}
}
cout <<endl;
}
void suijishu( )
{
int flag=0;
cin>>pc;
cout <<"******按照要求产生的320个随机数:*******" <<endl;
for(int i=0;i <320;i++)
{
temp[i]=pc;
if(flag%2==0) pc=++pc%320;
if(flag==1) pc=rand( )% (pc-1);
if(flag==3) pc=pc+1+(rand( )%(320-(pc+1)));
flag=++flag%4;
printf(" %03d",temp[i]);
if((i+1)%10==0) cout <<endl;
}
}
void pagestring( )
{
for(int i=0;i <320;i++)
{
printf(" %02d",temp[i]/10);
if((i+1)%10==0) cout <<endl;
}
}
void OPT( )
{ int exist,space,position ;
int curpage;
for(int i=0;i <320;i++)
{ if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace ( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ for(int k=0;k <Bsize;k++)
{for(int j=i;j <320;j++)
{if(block[k].pagenum!= temp[j]/10)
{ block[k].accessed = 1000;
}//将来不会用,设置为一个很大数
else
{ block[k].accessed = j;
break;
}
}
}
position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
}
cout <<"缺页次数:" << n <<endl;
cout <<"缺页率:" <<(n/320.0)*100 <<"%" <<endl;
}
void LRU( )
{ int exist,space,position ;
int curpage;
for(int i=0;i <320;i++)
{ if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
else block[exist].accessed = -1;//恢复存在的并刚访问过的BLOCK中页面accessed为-1
for(int j=0; j <4; j++)
{
block[j].accessed++;
}
}
cout <<"缺页次数:" <<n <<endl;
cout <<"缺页率:" <<(n/320.0)*100 <<"%" <<endl;
}
void FIFO( )
{
int exist,space,position ;
int curpage;
for(int i=0;i <320;i++)
{
if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
block[position].accessed--;
}
}
for(int j=0; j <Bsize; j++)
block[j].accessed++;}
cout <<"缺页次数:" <<n <<endl;
cout <<"缺页率:" <<(n/320.0)*100 <<"%" <<endl;
}
void main( )
{
int select;
cout <<"请输入第一条指令号(0~320):";
suijishu( );
cout <<"*****对应的调用页面队列*******" <<endl;
pagestring( );
do
{ cout <<"****************************************" <<endl;
cout <<"------1:OPT 2:LRU 3:FIFO 4:退出-----" <<endl;
cout <<"****************************************" <<endl;
cout <<" 请选择一种页面置换算法:";
cin>>select;
cout <<"****************************************" <<endl;
init( );
switch(select)
{ case 1:cout <<"最佳置换算法OPT:" <<endl;
cout <<"*****************" <<endl;
OPT( );
break;
case 2:cout <<"最近最久未使用置换算法LRU:" <<endl;
cout <<"**************************" <<endl;
LRU( );
break;
case 3:cout <<"先进先出置换算法FIFO:" <<endl;
cout <<"*********************" <<endl;
FIFO( );
break;
default: ;
}
}while(select!=4);
}

  • 打赏
  • 举报
回复
#include "iostream.h"
改为#include <iostream>
using namespace std;
不信你还有问题。

sagegz 2009-01-02
  • 打赏
  • 举报
回复
VS2005下,我简单的帮你改了改,编译通过了,其他的错误你自己再调试吧.


//#include "iostream.h"
//改为
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
//下面能通过?
//#include "stdafx.h"
//使用命名空间std
using namespace std;

#define Bsize 4
typedef struct BLOCK//声明一种新类型——物理块类型
{ int pagenum;//页号
int accessed;//访问字段,其值表示多久未被访问
}BLOCK;
int pc;//程序计数器,用来记录指令的序号
int n;//缺页计数器,用来记录缺页的次数
static int temp[320];//用来存储320条随机数
BLOCK block[Bsize]; //定义一大小为4的物理块数组
void init( ); //程序初始化函数
int findExist(int curpage);//查找物理块中是否有该页面
int findSpace( );//查找是否有空闲物理块
int findReplace( );//查找应予置换的页面
void display ( );//显示
void suijishu( );//产生320条随机数,显示并存储到temp[320]
void pagestring( );//显示调用的页面队列
void OPT( );//OPT算法
void LRU( );// LRU算法
void FIFO( );//FIFO算法

void init( )
{
for(int i=0;i <Bsize;i++)
{
block[i].pagenum=-1;
block[i].accessed=0;
pc=n=0;
}
}

//返回值有问题
int findExist(int curpage){
for(int i=0; i <Bsize; i++){
if(block[i].pagenum == curpage )
return i;//检测到内存中有该页面,返回block中的位置
}
//return -1放下面
return -1;
}

int findSpace( )
{
for(int i=0; i <Bsize; i++)
{
if(block[i].pagenum == -1)
return i;//找到空闲的block,返回block中的位置}
} return -1;
}
int findReplace( ){
int pos = 0;
for(int i=0; i <Bsize; i++){
if(block[i].accessed >block[pos].accessed)
pos = i;//找到应予置换页面,返回BLOCK中位置
return pos;
}
//这里需要返回值,没找到返回0
return 0;
}
void display( )
{ for(int i=0; i <Bsize; i++)
{ if(block[i].pagenum != -1)
{
printf(" %02d",block[i].pagenum);
}
}
cout <<endl;
}
void suijishu( )
{
int flag=0;
cin>>pc;
cout <<"******按照要求产生的320个随机数:*******" <<endl;
for(int i=0;i <320;i++)
{
temp[i]=pc;
if(flag%2==0) pc=++pc%320;
if(flag==1) pc=rand( )% (pc-1);
if(flag==3) pc=pc+1+(rand( )%(320-(pc+1)));
flag=++flag%4;
printf(" %03d",temp[i]);
if((i+1)%10==0) cout <<endl;
}
}
void pagestring( )
{
for(int i=0;i <320;i++)
{
printf(" %02d",temp[i]/10);
if((i+1)%10==0) cout <<endl;
}
}
void OPT( )
{ int exist,space,position ;
int curpage;
for(int i=0;i <320;i++)
{ if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace ( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ for(int k=0;k <Bsize;k++)
{for(int j=i;j <320;j++)
{if(block[k].pagenum!= temp[j]/10)
{ block[k].accessed = 1000;
}//将来不会用,设置为一个很大数
else
{ block[k].accessed = j;
break;
}
}
}
position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
}
cout <<"缺页次数:" << n <<endl;
cout <<"缺页率:" <<(n/320.0)*100 <<"%" <<endl;
}
void LRU( )
{ int exist,space,position ;
int curpage;
for(int i=0;i <320;i++)
{ if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
else block[exist].accessed = -1;//恢复存在的并刚访问过的BLOCK中页面accessed为-1
for(int j=0; j <4; j++)
{
block[j].accessed++;
}
}
cout <<"缺页次数:" <<n <<endl;
cout <<"缺页率:" <<(n/320.0)*100 <<"%" <<endl;
}
void FIFO( )
{
int exist,space,position ;
int curpage;
for(int i=0;i <320;i++)
{
if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
block[position].accessed--;
}
}
for(int j=0; j <Bsize; j++)
block[j].accessed++;}
cout <<"缺页次数:" <<n <<endl;
cout <<"缺页率:" <<(n/320.0)*100 <<"%" <<endl;
}
void main( )
{
int select;
cout <<"请输入第一条指令号(0~320):";
suijishu( );
cout <<"*****对应的调用页面队列*******" <<endl;
pagestring( );
do
{ cout <<"****************************************" <<endl;
cout <<"------1:OPT 2:LRU 3:FIFO 4:退出-----" <<endl;
cout <<"****************************************" <<endl;
cout <<" 请选择一种页面置换算法:";
cin>>select;
cout <<"****************************************" <<endl;
init( );
switch(select)
{ case 1:cout <<"最佳置换算法OPT:" <<endl;
cout <<"*****************" <<endl;
OPT( );
break;
case 2:cout <<"最近最久未使用置换算法LRU:" <<endl;
cout <<"**************************" <<endl;
LRU( );
break;
case 3:cout <<"先进先出置换算法FIFO:" <<endl;
cout <<"*********************" <<endl;
FIFO( );
break;
default: ;
}
}while(select!=4);
}
xuruichen 2009-01-02
  • 打赏
  • 举报
回复
用using namespace std;
eniyi 2009-01-02
  • 打赏
  • 举报
回复
我用的是VS2005
良枫 2009-01-02
  • 打赏
  • 举报
回复
试了下LZ修改后的代码,可以编译通过.(可能因为以文本方式贴的所以 < < 多了个空格,去掉后编译通过了,有两个警告)
LZ重新建个工程再试一下吧
eniyi 2009-01-02
  • 打赏
  • 举报
回复
#include<iostream>
using namespace std;
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <stdafx.h>
#define Bsize 4
typedef struct BLOCK//声明一种新类型——物理块类型
{ int pagenum;//页号
int accessed;//访问字段,其值表示多久未被访问
}BLOCK;
int pc;//程序计数器,用来记录指令的序号
int n;//缺页计数器,用来记录缺页的次数
static int temp[320];//用来存储320条随机数
BLOCK block[Bsize]; //定义一大小为4的物理块数组
void init( ); //程序初始化函数
int findExist(int curpage);//查找物理块中是否有该页面
int findSpace( );//查找是否有空闲物理块
int findReplace( );//查找应予置换的页面
void display ( );//显示
void suijishu( );//产生320条随机数,显示并存储到temp[320]
void pagestring( );//显示调用的页面队列
void OPT( );//OPT算法
void LRU( );// LRU算法
void FIFO( );//FIFO算法
void init( )
{
for(int i=0;i<Bsize;i++)
{
block[i].pagenum=-1;
block[i].accessed=0;
pc=n=0;
}
}
int findExist(int curpage)
{
for(int i=0; i<Bsize; i++)
{
if(block[i].pagenum == curpage )
return i;//检测到内存中有该页面,返回block中的位置}
return -1;
}
}
int findSpace( )
{
for(int i=0; i<Bsize; i++)
{
if(block[i].pagenum == -1)
return i;//找到空闲的block,返回block中的位置}
} return -1;
}
int findReplace( )
{
int pos = 0;
for(int i=0; i<Bsize; i++)
{
if(block[i].accessed >block[pos].accessed)
pos = i;//找到应予置换页面,返回BLOCK中位置 }
return pos;
}
}
void display( )
{ for(int i=0; i<Bsize; i++)
{ if(block[i].pagenum != -1)
{
printf(" %02d",block[i].pagenum);
}
}
cout<<endl;
}
void suijishu( )
{
int flag=0;
cin>>pc;
cout<<"******按照要求产生的320个随机数:*******"<<endl;
for(int i=0;i<320;i++)
{
temp[i]=pc;
if(flag%2==0) pc=++pc%320;
if(flag==1) pc=rand( )% (pc-1);
if(flag==3) pc=pc+1+(rand( )%(320-(pc+1)));
flag=++flag%4;
printf(" %03d",temp[i]);
if((i+1)%10==0) cout<<endl;
}
}
void pagestring( )
{
for(int i=0;i<320;i++)
{
printf(" %02d",temp[i]/10);
if((i+1)%10==0) cout<<endl;
}
}
void OPT( )
{ int exist,space,position ;
int curpage;
for(int i=0;i<320;i++)
{
if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace ( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ for(int k=0;k<Bsize;k++)
{for(int j=i;j<320;j++)
{if(block[k].pagenum!= temp[j]/10)
{ block[k].accessed = 1000;
}//将来不会用,设置为一个很大数
else
{ block[k].accessed = j;
break;
}
}
}
position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
}
cout<<"缺页次数:"<<n<<endl;
cout<<"缺页率:"<<(n/320.0)*100<<"%"<<endl;
}
void LRU( )
{ int exist,space,position ;
int curpage;
for(int i=0;i<320;i++)
{ if(i%100==0)
getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{ space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
}
}
else block[exist].accessed = -1;//恢复存在的并刚访问过的BLOCK中页面accessed为-1
for(int j=0; j<4; j++)
{
block[j].accessed++;
}
}
cout<<"缺页次数:"<<n<<endl;
cout<<"缺页率:"<<(n/320.0)*100<<"%"<<endl;
}
void FIFO( )
{
int exist,space,position ;
int curpage;
for(int i=0;i<320;i++)
{
if(i%100==0) getch( );
pc=temp[i];
curpage=pc/10;
exist = findExist(curpage);
if(exist==-1)
{space = findSpace( );
if(space != -1)
{ block[space].pagenum = curpage;
display( );
n=n+1;
}
else
{ position = findReplace( );
block[position].pagenum = curpage;
display( );
n++;
block[position].accessed--;
}
}
for(int j=0; j<Bsize; j++)
block[j].accessed++;}
cout<<"缺页次数:"<<n<<endl;
cout<<"缺页率:"<<(n/320.0)*100<<"%"<<endl;
}
void main( )
{
int select;
cout<<"请输入第一条指令号(0~320):";
suijishu( );
cout<<"*****对应的调用页面队列*******"<<endl;
pagestring( );
do
{ cout<<"****************************************"<<endl;
cout<<"------1:OPT 2:LRU 3:FIFO 4:退出-----"<<endl;
cout<<"****************************************"<<endl;
cout<<" 请选择一种页面置换算法:";
cin>>select;
cout<<"****************************************"<<endl;
init( );
switch(select)
{ case 1:cout<<"最佳置换算法OPT:"<<endl;
cout<<"*****************"<<endl;
OPT( );
break;
case 2:cout<<"最近最久未使用置换算法LRU:"<<endl;
cout<<"**************************"<<endl;
LRU( );
break;
case 3:cout<<"先进先出置换算法FIFO:"<<endl;
cout<<"*********************"<<endl;
FIFO( );
break;
default: ;
}
}while(select!=4);
}

改了,可还是出现:
错误 1 error C2065: “cout”: 未声明的标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 69
错误 2 error C2065: “endl”: 未声明的标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 69
错误 3 error C2065: “cin”: 未声明的标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 74
错误 4 error C3861: “rand”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 80
错误 5 error C3861: “rand”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 81
错误 6 error C3861: “getch”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 100
错误 7 error C3861: “getch”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 138
错误 8 error C3861: “getch”: 找不到标识符 c:\documents and settings\administrator\桌面\czxtkcsj\czxtkcsj\czxtkcsj.cpp 171
timefinger 2009-01-02
  • 打赏
  • 举报
回复
cout改为std::cout其他类似加std::
keven1868 2009-01-02
  • 打赏
  • 举报
回复
#include <iostream>
using namespace std;
eniyi 2009-01-02
  • 打赏
  • 举报
回复
改了,还是不行:
#include<iostream>
using namespace std;
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include "stdafx.h"
#define Bsize 4
xuruichen 2009-01-02
  • 打赏
  • 举报
回复
楼主只有自己定义的HPP
文件才能
#include ""
这是常识。
标准库的类文件用尖括号<>

gl615 2009-01-02
  • 打赏
  • 举报
回复
第一行:#include "iostream.h"

改为:#include <iostream.h>
或:#include <iostream>
using namespace std;

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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