c++的问题 高手来

来源:百度知道 编辑:UC知道 时间:2024/07/11 22:21:35
c:\documents and settings\administrator\桌面\11\11.cpp(1) : fatal error C1083: Cannot open include file: 'iostrem': No such file or directory
执行 cl.exe 时出错.

只个不知道什么问题 出现在那

这是我的代码

#include <iostrem>
using namespace std;
void swap(int ,int );
int main()
{
int x=3,y=4;
cout<<"在MAIN函数中,调用swap函数之前,x的值为:"<<x<<",y的值为:"<<y<<endl;
swap(x,y);
cout<<"在MAIN函数中,调用swap函数之后,x的值为:"<<x<<",y的值为:"<<y<<endl;
return 0;
}
void swap(int x,int y)
{
cout<<"在swap函数中,调用swap函数之后,x的值为:"<<x<<",y的值为:"<<y<<endl;
int z;
z=x
x=y
y=z
cout<<"在swap函数中,调用swap函数之前,x的值为:"<<x<<",y的值为:"<<y<<endl;
}

#include <iostrem>
改成
#include <iostream>

#include <iostrem>
头文件错误

已经有错误提示了,找不到'iostrem'

其实是你程序输错了,应该是
#include <iostream>

明明白白告诉你 你又复制了一遍 然后你还问我 我也不知道说什么好

首先不是“iostrem”,是“iostream”。
其次你这个函数目的是为了交换x,y的值,你完成的知识形参的交换,而没有交换实参,建议用指针编写。下面是代码:
#include <iostream>
using namespace std;
void swap(int *,int *);
int main()
{
int x=3,y=4;
int a,b;
a=&x;
b=&y;
cout<<"在MAIN函数中,调用swap函数之前,x的值为:"<<x<<",y的值为:"<<y<<endl;
swap(a,b);
cout<<"在MAIN函数中,调用swap函数之后,x的值为:"<<x<<",y的值为:"<<y<<endl;
return 0;
}
void swap(int * ptr1,int * ptr2)
{
cout<<"在swap函数中,调用swap函数之后,x的值为:"<<x<<",y的值为:"<<y<<endl;
int z;
z=*ptr1;
*ptr1=*ptr2;
*ptr2=z;
cout<