猿问

我这个代码哪里错了?

#include "stdafx.h"
#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
double fact(int n)
{
double ft;
for(ft=1;n>=1;n--)
ft*=n;
return ft;
}
void main()
{
double m1,m2,a;
int t;
printf("Input t:\n");
scanf("%d",&t);
m1=fact(t);
printf("%d!=0",t);
printf("%lf\n",m1);
m2=fact(2+t);
printf("%d!=",2+t);
printf("%lf\n",m2);
}
getchar();
getchar();

return 0;
}

神不在的星期二
浏览 183回答 3
3回答

拉风的咖菲猫

c:\c\567\5556.cpp(1) : warning C4067: unexpected tokens following preprocessor directive - expected a newline&nbsp;解决此warning的办法是#include语句后不加分号#include "mex.h" &nbsp; &nbsp;%注意语句后没有分号哦~c:\c\567\5556.cpp(1) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory是在程序库路径设置上缺少添加库,导致程序编译的时候找不到头文件,在Tools -> Options -> Projects and Solutions -> VC++ Directories选项Show directories for选择include files,加入你库文件的路径,也可以在你程序中加入programma comment语句,然后把'bios.h'这个文件放在你工程所在的同一个文件夹里面

犯罪嫌疑人X

#include <stdio.h>double fact(int n){double ft;for(ft=1;n>=1;n--)ft*=n;return ft;}void main(){double m1,m2,a;int t;printf("Input t:\n");scanf("%d",&t);m1=fact(t);printf("%d!=0",t);printf("%lf\n",m1);m2=fact(2+t);printf("%d!=",2+t);printf("%lf\n",m2);getchar();getchar();}

慕桂英546537

大括号的个数不匹配,说白了就是多了一个大括号。你那_tmain函数被你贴过来的代码破坏了。把tmain那行删了再把getchar上面那个大括号删了
随时随地看视频慕课网APP
我要回答