!!!急急急急急急急急急急
有谁能帮我调一下,谢了
#ifndef _mystack_H__
#define _mystack_H__
#include <iostream>
#include <map>
#include <string>
//using namespace std;
typedef map<string,float> stringfloatmap;
typedef map<string,char> stringcharmap;
typedef map<string,string> stringstringmap;
class mystack()
{
private:
stringfloatmap sfmap;
stringcharmap scmap;
stringstringmap ssmap;
stringfloatmap :: iterator pos1;
stringcharmap :: iterator pos2;
stringstringmap :: iterator pos3;
public:
void ADD(string _string,float _float);
void ADD(string _string,char _char);
void ADD(string _string1,string _string2);
int FIN(string _string);
void DELE(string _string);
void ALTER(string _string,float _float);
void ALTER(string _string,char _char);
void ALTER(string _string1,string _string2);
}
void mystack::ADD(string _string,float _float)
{
sfmap[_string]=_float;
}
void mystack::ADD(string _string,char _char)
{
scmap[_string]=_char;
}
void mystack::ADD(string _string1,string _string2)
{
sfmap[_string]=_string;
}
int mystack::FIN(string _string)
{
pos1=sfmap.find(_string);
if(pos1!=sfmap.end())
{
cout<<pos1->first<<":"<<pos1->second<<endl;
}
else
{
pos2=scmap.find(_string);
if(pos2!=scmap.end())
{
cout<<pos2->first<<":"<<pos2->second<<endl;
}
else
{
pos3=ssmap.find(_string);
if(pos13=ssmap.end())
{
cout<<pos3->first<<":"<<pos3->second<<endl;
}
else
{
cout<<"HAVE NOT FINDED!!"<<endl;
return 0;
}
}
}
return 1;
}
void mystack::DELE(string _string)
{
stringfloatmap::iterator pos1;
stringcharmap::iterator pos2;
stringstringmap::iterator pos3;
pos1=sfmap.find(_string);
if(pos1!=sfmap.end())
{
sfmap.erase(pos1);
cout<<"delete completed!!"<<endl;
}
else
{
pos2=scmap.find(_string);
if(pos2!=scmap.end())
{
scmap.erase(pos2);
cout<<"delete completed!!"<<endl;
}
else
{
pos3=ssmap.find(_string);
if(pos13=ssmap.end())
{
ssmap.erase(pos3);
cout<<"delete completed!!"<<endl;
}
else
{
cout<<"HAVE NOT FINDED!!"<<endl;
}
}
}
}
void mystack::ALTER(string _string,float _float)
{
stringfloatmap::iterator pos1;
pos1=sfmap.find(_string);
pos1->second=_float;
cout<<pos1->first<<":""<<pos1->second<<endl;
}
void mystack::ALTER(string _string,char _char)
{
stringcharmap::iterator pos2;
pos2=scmap.find(_string);
pos2->second=_char;
cout<<pos2->first<<":""<<pos2->second<<endl;
}
void mystack::ALTER(string _string1,string _string2)
{
stringstringmap::iterator pos3;
pos3=ssmap.find(_string1);
pos3->second=_string2;
cout<<pos3->first<<":"<<pos3->second<<endl;
}
#endif