好烦 !!函数嵌套问题

hehehengha1 2009-10-10 12:56:23
fact1 ,2,3怎样修改类型都不能通过,求教!!!!!!
#include<stdafx.h>
#include<iostream>
using namespace std;
void fact1(int n);
void fact2(int n);
int fact3(int n);
void main(){

int m;
m=fact1(3);
cout<<m<<endl;
}
void fact1(int n){
fact2(n);
}
void fact2(int n){
fact3(n);
}
int fact3(int n){
if(n==1)
return 1;
else
return n*fact3(n-1);
}
...全文
61 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hehehengha1 2009-10-11
  • 打赏
  • 举报
回复
哎 可能是我当时脑残哒,还是谢谢你!
hehehengha1 2009-10-10
  • 打赏
  • 举报
回复
真希望高人指点一二…………
donkey301 2009-10-10
  • 打赏
  • 举报
回复
是不是把void都改为int就行了

#include <stdafx.h>
#include <iostream>
using namespace std;
int fact1(int n);
int fact2(int n);
int fact3(int n);
void main(){

int m;
m=fact1(3);
cout << m <<endl;
}
int fact1(int n){
return fact2(n);
}
int fact2(int n){
return fact3(n);
}
int fact3(int n){
if(n==1)
return 1;
else
return n*fact3(n-1);
}

33,027

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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