标题:[求助]我的这个程序哪里出问题了,请大家给看看吧,俺刚刚接触C++!
取消只看楼主
liujun850215
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-9
 问题点数:0 回复次数:2 
[求助]我的这个程序哪里出问题了,请大家给看看吧,俺刚刚接触C++!

#include<iostream.h>
int power(int a,int n)
void main()
{int a,n;
cout<<"please input a and n:"<<endl;
cin>>a>>n;
cout<<endl;
cout<<power(a,n);}
int power(int a,int n)
{if(n==1) return a;
else if(n>1) return a*power(a,n-1);}
这是求一个数A的N次方,用的函数递归调用!

2007-04-10 16:07
liujun850215
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-9
得分:0 

我加上分号了,可还是说有错误,请指明!

2007-04-10 16:55
liujun850215
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-4-9
得分:0 
#include<iostream.h>
int power(int a,int n);
void main()
{int a,n,s;
cout<<"please input a and n:";
cin>>a;
cin>>n;
cout<<endl;
cout<<power(a,n);}
int power(int a,int n)
{if(n==1) return a;
else if(n>1) return a*power(a,n-1);}
我把程序改成这个样子了,说是没错误了,但运行一下,什么也不出呀!这是怎么会事,晕了!
2007-04-10 17:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-130765-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.201600 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved