No such file or directory
答案:2 悬赏:40
解决时间 2021-02-18 13:59
- 提问者网友:风华是一指流沙
- 2021-02-18 05:47
//factorial.h
int factorial(int n);
//factorial.cpp
#include"factorial.h"
int factorial(int n)
{ int i,f=1;
for(i=2;i<=n;i++)
f *=i;
return f;
}
//power.h
double power(double x,int n);
//power.cpp
#include"power.h"
double power(double x,int n)
{ if(x==0) return 0;
double product=1.0;
if(n>=0)
while(n>0)
{ product *=x;
n--;
}
else
while(n>0)
{ product /=x;
n++;
}
return product;
//main.cpp
#include
using namespace std;
#include"factorial.h"
#include"power.h"
int main()
{int n;
cin>>n;
cout< double d;
cin>>d;
cout< return 0;
}
提示的错误是:fatal error C1083: Cannot open include file: 'factorial.h': No such file or directory!
最佳答案
- 二级知识专家网友:转身后的回眸
- 2021-02-18 07:02
//factorial.h
//int factorial(int n);
//factorial.cpp
//#include"factorial.h"
#include
//using namespace std;
int factorial(int n)
{ int i,f=1;
for(i=2;i<=n;i++)
f *=i;
return f;
}
//power.h
//double power(double x,int n);
//power.cpp
//#include"power.h"
double power(double x,int n)
{ if(x==0) return 0;
double product=1.0;
if(n>=0)
while(n>0)
{ product *=x;
n--;
}
else
while(n>0)
{ product /=x;
n++;
}
return product;
}
//main.cpp
//#include"factorial.h"
//#include"power.h"
int main()
{
int n;
cin>>n;
cout<
double d;
cin>>d;
cout<
return 0;
}
全部回答
- 1楼网友:傲娇菇凉
- 2021-02-18 08:15
cout<<‘最大数是:“<<max(i,j)<<'/n';
这句改成:
cout<<"最大数是:"<<max(i,j)<<endl;
还有,
int main()就可以了
一般来说,诡异的编译错误都是由于简单的地方出现错误导致的
那种中间的临时文件无关紧要,都是编译器自己生成的,是因为代码的错误才导致的问题。
另外的另外,最好不要再用#include<iostream.h>(这个已经很过时很过时了。。。)
全部换成
#include<iostream>
using namespace std;
我把程序修改成:
# include<iostream>
using namespace std;
int max(int i,int j)
{
if(i>=j)return i;
else return j;
}
int main(void)
{
cout<<"输入i,j;";
int i,j;
cin>>i>>j;
cout<<"最大数是:"<<max(i,j)<<endl;
return 0;
}
结果是:
--------------------configuration: cpp1 - win32 debug--------------------
compiling...
cpp1.cpp
linking...
cpp1.exe - 0 error(s), 0 warning(s)
我要举报
大家都在看
推荐资讯