求高手帮忙把下面的程序改成C++,不胜感激啊啊啊啊!!!!

#include<iostream>#include<vector>#include<string.h>usingnamespacestd;#defineBUFFERSI... #include <iostream>
#include <vector>
#include <string.h>
using namespace std;

#define BUFFERSIZE 40

char num[BUFFERSIZE]={0};
vector<string> temp;
vector<string> result;
double maxProduct=0;
bool getAmaxproduct=false;

void maxproduct(char* s, int n,int k)
{
vector<string>::iterator p;
if(k==0)
{
getAmaxproduct=true;
temp.push_back(s);
double product=1;

for (p=temp.begin(); p!=temp.end(); p++)
{
product *= atoi((*p).c_str());
}
if(product > maxProduct)
{
maxProduct = product;
result.clear();
result=temp;
}
}
else
{
for(int i=1; i<=n-k; i++)
{
if(getAmaxproduct)
{
int poplength=0;
for(p=temp.end()-1; poplength!=n; temp.pop_back(),p=temp.end()-1)
{poplength += (*p).size();}
getAmaxproduct=false;
}
char *tmp=new char[BUFFERSIZE];
memset(tmp,0,BUFFERSIZE);
for(int j=0; j<i; j++)
{
if (tmp[0]==0)
tmp[0]=*(s+j);
else
tmp[strlen(tmp)] = *(s+j);
}
temp.push_back(tmp);
maxproduct(s+i,n-i,k-1);
}
}

}

void main()
{
int k,n;
cout<<"Please input n and k (2≤N≤40,1≤K≤6):\n";
cin>>n>>k;
cout<<"Please input num:\n";
cin>>num;
if(n>=2&&n<=40&&k>=1&&k<=6)
{

if(n !=strlen(num))
{
cout<<"请确保输入的字符串的长度=n\n";
return;
}
if (n<=k)
{
cout<<num<<"中输入"<<k<<"个乘号不能分成 "<<k<<"+1部分\n";
return;
}
maxproduct(num,n,k);

cout<<num<<"中输入"<<k<<"个乘号分成"<<k<<"+1部分的最大乘积= \n";
for(vector<string>::iterator p=result.begin(); p!=result.end(); p++)
{
cout<<(*p).c_str();
if (p==result.end()-1)
{cout<<" = "; }
else
cout<<"*";
}
cout<< maxProduct<<endl;
}

else
cout<<"请重新输入n和k(2≤N≤40,1≤K≤6)";
}
我也觉得是啊,但是木有类啊
展开
 我来答
tseug8271
2012-06-18 · TA获得超过1499个赞
知道小有建树答主
回答量:745
采纳率:100%
帮助的人:424万
展开全部
难道这段代码不是C++?
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式