[b][size=6][b] 要求: [/b] [/size] [/b]

  有一个公司,这个公司计划发行一千万股份(每股为$10)该公司按下面的四种类型来分配股份:

     常驻的
     非常驻的
     国内的公司
     国外的公司
 有一个管理部门因此决定用计算机处理公司的参股帐目系统来维护股东的详细资料.主要意见如下:
  
   该公司需要更多的共有资金来使其通信产品多样化
   该公司需要发行49%的股份来控制该公司的所有权
   该公司需要完全基于先来先服务的原则来分配股份
   提供的股份应该是以50的倍数来增加
  该项目被命名为ShareAccounting

  对该系统有如下的期望:

    数据库将可以维护申请者的详细资料
     该参股帐目系统应该可以进行适当的检查
    该参股帐目系统应该可以打印清晰的种类分配列表
    该参股帐目系统应该可以打印清晰的种类最大分配列表
    该参股帐目系统应该可以打印清晰的日期分配列表

#include<sybfront.h>
#include<sybdb.h>
#include<syberror.h>
#include<stdlib.h>
#include<iostream>
#include<string>
using namespace std;
struct Node
{
    string name;
    Node *NEXT;
    /*The default initialization of the NEXt pointer is null*/
    /* The name is initialized to a string */
    Node(const string &s,Node *n = NULL):name (s),NEXT (n)
    {
    }
}; 
class  mainMenu 
{
  public:
  mainMenu ();
  void display();
};
mainMenu::mainMenu()
{
  cout<<"**************************************************"<<endl;
   cout << endl << "1.Enter shareholder name\n"<<endl;
   cout << "2. delete shareholder name from Administer\n"<<endl;
   cout << "3. search for a sharecerticate\n"<<endl;
   cout << "4.display the names of all shareholder\n"<< endl;
   cout << "5.exit\n"<< endl;
   cout <<"        Welcome to the Sharecertificate  system!    " <<endl;
   cout << endl;
   cout << "Please choice which option is you need:"<<endl;
}
void mainMenu::display()
{
   cout << "1.commodity"<<endl;
   cout << "2.Adminiter "<<endl;
   cout << "3. Genger  " <<endl;
   cout <<" 4. sharecertificate "<<endl;
   cout <<" 5.exit "<<endl;
}
class Administer
{
  private :
   Node *START;//pointer to start of list
   Node *CURRENT;//Used by queryNode() and delNode()
   Node *PRECEDE;//Used by qreryNode() and delNode()
 char Password[20];
 char cName[20];
 char cCompany[30];
 char *cCode;
 char *cType;
 int nMix;
 int nMax;
 int nTotal;
public:
    Administer();
    /*~Administer()
    {
    destroy();
    }*/
    void accept();
    void traverse();//Display name in all the Nodes
    void addNode(const string &s);//adds a Node
    bool queryNode(const string &s);//Searches for a given name and 
                                    //repositions CURRENT and PRECEDE
    bool delNode(const string &s);//deletes a Node
    void destory();//deletes all nodes from the Administe
};
void Administer::accept()
{
    cout <<"please your password:     ";
    cin >> Password;
    cout << "please your name:    ";
    cin >> cName;
    cout << "please your commpany:    ";
    cin >> cCompany;
    cout << "Please your code:    ";
    cin >> cCode;
    cout << "please your type:   ";
    cin >> cType;
}
 Administer::Administer()
{
    /* Initialize all member pointers to Null*/
    START = CURRENT = PRECEDE = NULL;
}
void Administer::destory()
{
   /* Delete all NOdes in the Administer*/
   while (START != NULL)
   {
     CURRENT = START;
     START =START->NEXT;
     delete CURRENT;
   } 
   /* Initialize all member pointeres to NULL*/
   START = PRECEDE = CURRENT =NULL;
}
void Administer::addNode(const string &s)
{
    /* If the shareholer does not exit or name 
     is to be added at the Start */
     if (START == NULL || s<= START->name)
     {
      /*Construvtor for node update Next to either null  or
       to START depending on the state of the Administer*/
       return ;//No other steps need to be performed
     }
     /* If there are existing Nodes in the Administer ,
       company and Curr at the required Nodes*/
     Node *prev,*curr;//declare Node
     for ( prev = curr = START;curr != NULL && s > curr->name;
                                       prev = curr,curr = curr->NEXT)
         {
           
         } 
         Node *n = new Node (s,curr);//New Node's Next points to Curr
         prev->NEXT = n;
}    
bool Administer::queryNode(const string &s)
{
  /*Search the shareholder for the string ,return ture if 
  found */
  for(PRECEDE = CURRENT =START;CURRENT && s != CURRENT->name;
              PRECEDE = CURRENT,CURRENT = CURRENT->NEXT)
  {
    
  }
  /* return true if string is found int the Shareholder*/
  return (CURRENT != NULL);
}
void Administer::traverse()
{
   for(Node *temp = START;temp != NULL;temp = temp->NEXT)
   {
      cout << temp->name << endl;
   }
}
bool Administer::delNode(const string &s)
{
  /* if the required name is not found*/
  if (queryNode(s) == false)
  {
    return false;//Nothing else to be done
  }
  /* attach the previous node with the Next node*/
  PRECEDE->NEXT = CURRENT->NEXT;
  /*was the first node deleted?*/
  if (CURRENT == START)
  {
    START = START->NEXT;
  }
  delete CURRENT;
  return true;
}

class Generaler
{
  char password[10];
  char cname[20];
  char cId[18];
  char *cCompanytype;
  char cRepresenter[20];
  int nNumber;
  float nAmount;
  double nRate;
  char *cCompany;
  public:
  void accept();
  void encryptChar();
  void print();
};
void Generaler::accept()//accept information
{
    cout <<"please your password:     ";
    cin >> password;
    cout << "please your name:    ";
    cin >> cname;
    cout << "please your commpany:    ";
    cin >> cCompany;
    cout << "please your companytype:  ";
    cin >> cCompanytype;
    cout << "please your representer:   ";
    cin >> cRepresenter;
    cout << "please enter your company:   ";
    cin >> cCompany;
}
void Generaler::encryptChar()
{
     int i;
     char *pf;
     for(i = 0;i<5000000;i++)//number loop
     {
      while(*pf >= 10)
      {
      if (*pf%50 ==0)//divide 50
       cout << "Please enter your sharenumber"<< *pf <<endl;
      else 
       cout << "Please exit"<<endl;
      }
     }
}
void Generaler::print()
{
      cout << "Please print your information:   " << endl;
      cout << "Please your name:  " << cname << endl;
      cout << "Please your cId:   "<<cId << endl;
      cout << "Please your company:  "<< cCompany << endl;
      cout << "Please your nType:   " << cCompanytype << endl;
}
int main()
{
  DBPROCESS *Dbproc;//struct
  LOGINREC *Login;//struct
  char cUsername[30];
  char cPassword[10];//declare arr
  DBCHAR cX[8];
  Login = dblogin();//accpet customer and command
  cout << "Enter your user name"<<endl;
  cin >> cUsername;
  //cout << "Enter the password";
  //cin >> cPassword;
  dbinit();
  DBSETLUSER(Login,cUsername);
  DBSETLPWD(Login,"");
  //buit link
  Dbproc = dbopen(Login,"192.168.0.1:1433");
  //check customer
  if(Dbproc == NULL)
      exit(1);
  //break proc
  dbuse(Dbproc,"ShareAccounting");
  dbcmd(Dbproc,"select * from  ShareCertificate");
  dbsqlexec(Dbproc);
  dbresults(Dbproc);
  dbbind(Dbproc,1,CHARBIND,0,(BYTE *)&cX);
  //cout << cX << endl;
  while(dbnextrow(Dbproc)!= NO_MORE_ROWS)
  {
     cout << cX << endl;
  }
  cout << "1"<<endl;
  Administer obj;
  Generaler project;
     char ch;
     while(1)//The condition of the loop is always true
     {
      mainMenu obj1;
       cin >> ch;
       switch(ch)
       {
        case '1':
          {
            cout << endl << "enter a name:";
            string s;
            cin.ignore();
            getline(cin,s);
            obj.addNode(s);
          }
          break;
        case '2':
           {
              cout << endl<< "Enter a name:";
              string s;
              cin.ignore();
              getline(cin,s);
              if(obj.delNode(s) == false)
              {
                 cout << "shareholder not found" << endl;
              }
           }
           break;
        case '3':
           {
              cout<< endl << "enter a name:";
              string s;
              cin.ignore();
              getline(cin,s);
              if(obj.queryNode(s) == false)
              {
                 cout << "shareholder not found" << endl;
              }
              else 
              {
                  cout << "shareholder found in Administer"<< endl;
              }
           }
           break;
        case '4':
           obj.traverse();
           break;
        case '5':
           exit(1);//end the program
           break;
        default:
           cout << endl << "Enter a correct choice";
           break;
       }
     }
     project.encryptChar();
  system("pause");
  return 0;
}