2 回答

TA贡献1995条经验 获得超2个赞
void print(string* months)
{
int i;
for(i=0;i<12;i++)
cout<<*months++<<endl;
}
这个很容易想到的吗!
也不知你用的啥编译器,你的这个程序,哥用g++编译运行,一切ok,没出现异常,但最好别这样写~。

TA贡献1794条经验 获得超8个赞
//---------------------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;
int main()
{
void print(string* months,int n);
string months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"};
print(months,12);
return 0;
}
void print(string* months,int n)
{
if (n) {
cout<<*months<<endl;
print(months+1,n-1);
}
}
//---------------------------------------------------------------------------
- 2 回答
- 0 关注
- 115 浏览
添加回答
举报