命令行选项那个题目就不再粘出来了,想问一下我的代码如下(有点麻烦):
#include
#include
#include
using namespace std;
int main(int argc,char** argv)
{
map Order1;
string s;
cin>>s;
int num;
cin >> num;
//cout<<"??"<< endl;
char order_temp[260];
for(int i = 0;s[i]!='\0';i++)
{
if(s[i]==':')
continue;
else
{
if(Order1.find(s[i])!=Order1.end())
continue;
else
{
if(s[i+1]==':')
Order1.insert(pair(s[i],1));//1代表有参数
else
Order1.insert(pair(s[i],0));
}
}
}
cin.getline(order_temp,260);
for(int i = 0;i {
map Order=Order1;
string prt;
cin.getline(order_temp,260);
map ans;
for(int j = 0;order_temp[j]!='\0';j++)
{ //cout<< i< if(order_temp[j]=='-')
{
if((order_temp[j-1]!=' ')&&(order_temp[j+2]!=' ')&&(order_temp[j+2]!='\0'))
break;
else
{
map::iterator its;
its = Order.find(order_temp[j+1]);
if(its==Order.end())
{ //cout <<"????"< break;
}
else
{
if(its->second==0)//无参
{
char a = its->first;
Order.erase(its);
Order.insert(pair(a,2));
ans.insert(pair(its->first,"*"));
}
else if(its->second==1)
{
if(order_temp[j+2]=='\0')
break;
else
{
char a = its->first;
Order.erase(its);
Order.insert(pair(a,3));
string temp;
for(int k = j+3;order_temp[k]!=' ';k++)
temp = temp + order_temp[k];
ans.insert(pair(its->first,temp));
}
}
else if(its->second==2)
{
//cout<second;
break;
}
else
{
string temp;
if(order_temp[j+2]=='\0')
temp = '\0';//此处有疑问
for(int k = j+3;((order_temp[k]!=' ')&&(order_temp[k]!='\0'));k++)
temp = temp + order_temp[k];
map::iterator de;
de = ans.find(its->first);
ans.erase(de);
ans.insert(pair(its->first,temp));
}
}
}
}
else
continue;
}
map::iterator out;
cout<<"Case "<<i+1<<":";
for(out=ans.begin();out!=ans.end();out++)
{
if(out->second!="*")
cout<<" "<<'-'<<out->first<<" "<<out->second;
//prt=prt + " " + '-' + out->first + " " + out->second ;
else
cout<<" "<<'-'<<out->first;
//prt=prt + " " + '-' + out->first ;
}
cout<<endl;
}
return 0;
}
为什么输出和要求一样,可是得分是0呢?求发审解答~~
看下是不是代码写错了造成的。
看看是不是条件 或代码的原因