⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emp2_03.cpp

📁 该包是数据结构的实验软件,来源于合肥工业大学人工智能与数据挖掘实验室,用来实现数据结构.
💻 CPP
字号:
 #include"seqlists.h"
 void  StrToSeqList(string s,SeqList& A)
 {int i,L;
 boolean suc;
     L=strlen(s);
     i=L-1;
     suc=true;

      while ((i>=0)&&(suc==1) )
	  {  if ((s[i]>='0')&& (s[i]<='9') )
		{   A.data[L-i]=s[i]-'0';
		    i=i-1;
		  }
	    else  suc=false;
	  }
      if (!suc)
	   Error_exit("There have illeage char in string");
      A.Last=strlen(s);
      for (i=A.Last+1;i<=SeqList_maxsub(A);i++)
	  A.data[i]=0;
    }


 int Cmp_SeqList(SeqList& A,SeqList& B)
   {
     int i,cmp;

     if ( A.Last>B.Last )
	cmp=1;
     else  if ( A.Last<B.Last)
	     cmp=-1;
	   else
	    {  i=A.Last;
	       cmp=0;
	       while ((i>=1)&&(cmp==0))
			 { cur_SeqList_elmn_onoff(A,i);
			   cur_SeqList_elmn_onoff(B,i);
			   getch();
			   if ( A.data[i]>B.data[i])  cmp=1;
			     else if (A.data[i]<B.data[i] ) cmp=-1;
			   cur_SeqList_elmn_onoff(A,i);
			   cur_SeqList_elmn_onoff(B,i);
			   i=i-1;
			  }
	      }
    int	Cmp_Seqlist=cmp;
    return Cmp_Seqlist;
 }

  main()
  {

  string s1,s2;
    SeqList A,B;
    set_SeqList_dir(A,"A",horizon,-1,1,15);
    set_SeqList_dir(B,"B",horizon,-1,1,15);
    s1="1234567";  s2="1234678";
  do
   {    gotoxy(1,1);
       StrToSeqList(s1,A);
       StrToSeqList(s2,B);
       move_SeqList_to(A,getmaxx()-150,100);
       move_SeqList_to(B,getmaxx()-150,300);
       switch( Cmp_SeqList(A,B))
	 {
	   case    0:    cout<<s1<<"="<<s2; break;
	   case    1:    cout<<s1<<">"<<s2; break;
	   case    -1:   cout<<s1<<"<"<<s2; break;
	  default:       cout<<"error!"<<endl;break;
	}
	   cout<<endl;
	      if (Answer_yes("Continue?y/n ") )

	    { Clear_range(0,0,600,60);
	      printf("%s","Num1=");//cout<<"Num1=";
	      scanf("%s",s1);//cin>>s1;
	      printf("%s","Num2=");//cout<<"Num1=";
	      scanf("%s",s2);
	     }
	       else
		   s1="";
     }
     while(strcmp(s1,"") );
      Wait();
      getch();
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -