为什么又不能运行!!!~

来源:百度知道 编辑:UC知道 时间:2024/05/26 02:31:31
#include <iostream>
using namespace std;
int main()
{
float x;
x=3.6;
int i;
i=(int)(x);
cout<<"i="<<i<<''<<"x="<<x<<endl;
system("pause");
return 0;
}
强制类型转换!~

cout<<"i="<<i<<''<<"x="<<x<<endl; 这里''里面没有字符,所以错误,改成:

#include <iostream>
using namespace std;
int main()
{
float x;
x=3.6;
int i;
i=(int)(x);
cout<<"i="<<i<<' '<<"x="<<x<<endl;
system("pause");
return 0;
}

你用了模板集,如果是在C++里编译,可以不用模板集,可以该成
#include <iostream.h>
int main()
{
....
}

using namespace std; system("pause"); 都可以省略吧 结果也是正确的 没问题