open officer by C.txt
上传用户:nt628733
上传日期:2022-07-18
资源大小:2k
文件大小:11k
源码类别:

文章/文档

开发平台:

Visual C++

  1. #include <iostream.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <string.h>
  6. class Ar1         //算法1
  7. {private:char ch;
  8.  public:void en()
  9.   {while(ch=getchar())  
  10.    { if ((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
  11.         {ch=ch+7;        
  12.       if(ch>'Z'&&ch<='Z'+7||ch>'z')
  13.                   ch=ch-26;
  14.       printf("%c",ch);  
  15.            }
  16.      else
  17.       if(ch!='n')     
  18.                  printf("%c",ch);
  19.       else          
  20.         break;
  21.    }
  22.   }
  23.   void un()                                                            
  24.         {while(ch=getchar())
  25.    {if ((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
  26.         {ch=ch-7;        
  27.       if(ch<'A'||ch>='a'-7&&ch<'a')
  28.                   ch=ch+26; 
  29.       printf("%c",ch);
  30.            }
  31.     else
  32.       if(ch!='n')
  33.                  printf("%c",ch);
  34.       else 
  35.         break;
  36.    }
  37.   }
  38. };
  39. class Ar2         //算法2                                                                            
  40. {private:int i,j,k;
  41.          char ch;
  42.    char A[26][3];
  43.  public:void en()                                                           
  44.         {char A[26][3]={"Ww","Yy","Hh","Dd","Aa",
  45.   "Oo","Ff","Uu","Ii","Mm","Ee","Rr","Vv",
  46.   "Ll","Gg","Zz","Bb","Tt","Cc","Jj","Nn",
  47.   "Ss","Pp","Kk","Xx","Qq"};  
  48.    while(ch=getchar())
  49.    if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
  50.    {for(j=0;j<2;j++)
  51.        for(i=0;i<26;i++)
  52.              {  if(ch==A[i][j])   
  53.         { k=(i+5)%26;    
  54.           ch=A[k][j];    
  55.        printf("%c",ch);
  56.        break;
  57.      }
  58.              }
  59.    }
  60.    else
  61.       if(ch!='n')        
  62.                  printf("%c",ch);   
  63.       else             
  64.         break;
  65.   }
  66.   void un()                                                            
  67.        
  68.           { char A[26][3]={"Jj","Mm","Zz","Dd","Aa",
  69.   "Oo","Gg","Uu","Ee","Yy","Ii","Rr","Vv",
  70.   "Ll","Ff","Xx","Bb","Tt","Cc","Ww","Nn",
  71.   "Ss","Pp","Kk","Hh","Qq"};    
  72.    while(ch=getchar())
  73.    if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
  74.    {for(j=0;j<2;j++)
  75.        for(i=0;i<26;i++)
  76.              {  if(ch==A[i][j])
  77.          {i=(i+26-5)%26;   
  78.           ch=A[i][j];
  79.        printf("%c",ch);
  80.        break;
  81.       }
  82.              }
  83.    }
  84.    else
  85.       if(ch!='n')
  86.                  printf("%c",ch); 
  87.       else           
  88.         break;
  89.   }
  90. };
  91. class Ar3         //算法3                                                            
  92. {private:char A[200];       
  93.          char a[100][5];     
  94.          char ch;
  95.          int i,j,k,n,m;
  96.  public:void en()                                                           
  97.   { k=0;m=0;
  98.     while((ch=getchar())!='n')
  99.              { A[k]=ch;      
  100.          k++;
  101.        }
  102.     if(k%5!=0)      
  103.        n=k/5+1;    
  104.     else
  105.     n=k/5;  
  106.      for(i=0;i<n;i++)    
  107.      { for(j=0;j<5;j++)
  108.      {a[i][j]=A[m];
  109.       m++;
  110.       if(m>k)   
  111.        a[i][j]=' ';
  112.       }
  113.      }
  114.      for(i=0;i<n/2;i++)    
  115.      { for(j=0;j<5;j++)     
  116.               { ch=a[i][j];
  117.        a[i][j]=a[n-1-i][j];
  118.                 a[n-1-i][j]=ch;
  119.      }
  120.      }
  121.      for(i=0;i<n;i++)    
  122.      { for(j=0;j<5;j++)
  123.        cout<<a[i][j];
  124.      }
  125.   }     
  126.   void un()                                                           
  127.   { k=0;m=0;
  128.     while((ch=getchar())!='n')
  129.              { A[k]=ch;       
  130.          k++;
  131.        }
  132.      n=k/5;           
  133.      for(i=0;i<n;i++)
  134.      { for(j=0;j<5;j++)
  135.      {a[i][j]=A[m];
  136.       m++;
  137.       if(m>k)
  138.        a[i][j]=' ';
  139.       }
  140.      }
  141.      for(i=0;i<n/2;i++)     
  142.      { for(j=0;j<5;j++)
  143.               { ch=a[i][j];
  144.        a[i][j]=a[n-1-i][j];
  145.                 a[n-1-i][j]=ch;
  146.      }
  147.      }
  148.      for(i=0;i<n;i++)    
  149.      { for(j=0;j<5;j++)
  150.        cout<<a[i][j];
  151.      }
  152.   }
  153. };
  154. class Ar4         //算法4                                                                            
  155. {private:char A[200];
  156.          char a[100][5];
  157.          char ch;
  158.          int i,j,k,n,m;
  159.  public:                                                                        
  160.      void en()  
  161.   { k=0;m=0;
  162.     while((ch=getchar())!='n')
  163.              { A[k]=ch;
  164.          k++;
  165.        }
  166.     if(k%5!=0)
  167.        n=k/5+1;     
  168.     else
  169.     n=k/5;  
  170.      for(i=0;i<n;i++)    
  171.      { for(j=0;j<5;j++)
  172.      {a[i][j]=A[m];
  173.       m++;
  174.       if(m>k)
  175.        a[i][j]=' ';
  176.       }
  177.      }
  178.      for(i=0;i<n;i++)     
  179.      {   ch=a[i][1];
  180.       a[i][1]=a[i][2];
  181.                a[i][2]=ch;
  182.       ch=a[i][3];
  183.       a[i][3]=a[i][4];
  184.                a[i][4]=ch;
  185.      }
  186.      for(i=0;i<n;i++)  
  187.      { for(j=0;j<5;j++)
  188.        cout<<a[i][j];
  189.      }
  190.   }     
  191.   void un()                                                           
  192.   { k=0;m=0;
  193.     while((ch=getchar())!='n')
  194.              { A[k]=ch;
  195.          k++;
  196.        }
  197.      n=k/5+1;           
  198.      for(i=0;i<n;i++)
  199.      { for(j=0;j<5;j++)
  200.      {a[i][j]=A[m];
  201.       m++;
  202.       if(m>k)
  203.        a[i][j]=' ';
  204.       }
  205.      }
  206.      for(i=0;i<n;i++)   
  207.      {   ch=a[i][1];
  208.       a[i][1]=a[i][2];
  209.                a[i][2]=ch;
  210.       ch=a[i][3];
  211.       a[i][3]=a[i][4];
  212.                a[i][4]=ch;
  213.      }
  214.      for(i=0;i<n;i++)       
  215.      { for(j=0;j<5;j++)
  216.        cout<<a[i][j];
  217.      }
  218.   }
  219. };class Va
  220. {private:int i;
  221.    char pa[4];
  222.  public:void sr()
  223.        {char x='*';  
  224.   for(int ii=1;ii<4;ii++)  
  225.   {for(i=0;i<5;i++)     
  226.     { pa[i]=getch();     
  227.             putchar(x);       
  228.     }
  229.    cout<<'n';
  230.          if(pa[0]=='y'&&pa[1]=='u'&&pa[2]=='a'&&pa[3]=='n')
  231.    {cout<<"登陆成功!"<<endl;
  232.     cout<<"欢迎您的使用!"<<endl;
  233.     cout<<"________________________________________________________________________________"<<endl;
  234.     cout<<"请输入需要使用的算法(Arithmetic:1/2/3/4)"<<endl;
  235.     break; 
  236.       }
  237.    else
  238.             {if(ii==3)
  239.     {cout<<"您是非法用户!按任意键退出程序。a"<<endl;
  240.      cout<<"________________________________________________________________________________"<<endl;
  241.      exit(0);
  242.     }  
  243.     else
  244.      cout<<"________________________________________________________________________________"<<endl;
  245.         cout<<"登陆口令输入错误!请重新输入:"<<endl;
  246.         cout<<"剩余限制次数:"<<3-ii<<"次"<<endl;
  247.     }
  248.   }
  249.     } 
  250. };
  251. void main()
  252. {int a,b;
  253.  cout<<"ttt Visual C++语言基础课程设计  "<<endl;
  254.  cout<<"nnn";
  255.  cout<<"请输入登陆口令:"<<endl;
  256.   Va us;
  257.  us.sr();
  258.  cout<<"使用算法:";
  259.  cin>>a;
  260.  cout<<"________________________________________________________________________________"<<endl;
  261.  switch(a)
  262. {case 1:Ar1 us1;
  263.    cout<<"需要加密还是解密(加密1/解密2)"<<endl;
  264.          cout<<"需要:";
  265.    cin>>a;
  266.    cout<<"________________________________________________________________________________"<<endl;
  267.    cout<<"加密解密说明:"<<endl;
  268.    cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
  269.    cout<<"________________________________________________________________________________"<<endl;
  270.    cout<<"请输入文字:"<<endl;
  271.    switch(a)
  272.    {case 1:us1.en();
  273.      cout<<endl;
  274.      cout<<"________________________________________________________________________________"<<endl;
  275.                  cout<<"是否需要解密(1是/2否)"<<endl;
  276.      cout<<"选择:";
  277.                  cin>>b;
  278.      cout<<"________________________________________________________________________________"<<endl;
  279.            if(b==1)
  280.      {cout<<"请输入文字:"<<endl;
  281.             us1.un();
  282.       cout<<endl;
  283.      }
  284.            else
  285.                    break;
  286.           case 2:us1.un();
  287.      cout<<"________________________________________________________________________________"<<endl;
  288.    }
  289.    cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
  290.    cout<<"ttt     程序结束,谢谢使用!"<<endl;
  291.    break;
  292.  case 2:Ar2 us2;   
  293.    cout<<"需要加密还是解密(加密1/解密2)"<<endl;
  294.          cout<<"需要:";
  295.    cin>>a;
  296.    cout<<"________________________________________________________________________________"<<endl;
  297.    cout<<"加密解密说明:"<<endl;
  298.    cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
  299.    cout<<"________________________________________________________________________________"<<endl;
  300.    cout<<"请输入文字:"<<endl;
  301.          switch(a)
  302.    {case 1:us2.en();
  303.                  cout<<endl;
  304.      cout<<"________________________________________________________________________________"<<endl;
  305.                  cout<<"是否需要解密(1是/2否)"<<endl;
  306.      cout<<"选择:";
  307.                  cin>>b;
  308.      cout<<"________________________________________________________________________________"<<endl;
  309.            if(b==1)
  310.      {cout<<"请输入文字:"<<endl;
  311.              us2.un();
  312.        cout<<endl;
  313.      }
  314.            else
  315.                    break;
  316.           case 2:us2.un();
  317.      cout<<"________________________________________________________________________________"<<endl;
  318.    }
  319.    cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
  320.    cout<<"ttt     程序结束,谢谢使用!"<<endl;
  321.    break;
  322.  case 3:Ar3 us3;    
  323.    cout<<"需要加密还是解密(加密1/解密2)"<<endl;
  324.          cout<<"需要:";
  325.    cin>>a;
  326.    cout<<"________________________________________________________________________________"<<endl;
  327.    cout<<"加密解密说明:"<<endl;
  328.    cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
  329.    cout<<"________________________________________________________________________________"<<endl;
  330.    cout<<"请输入文字:"<<endl;
  331.          switch(a)
  332.    {case 1:us3.en();
  333.                  cout<<endl;
  334.      cout<<"________________________________________________________________________________"<<endl;
  335.                  cout<<"是否需要解密(1是/2否)"<<endl;
  336.      cout<<"选择:";
  337.                  cin>>b;
  338.      cout<<"________________________________________________________________________________"<<endl;
  339.            if(b==1)
  340.      {cout<<"请输入文字:"<<endl;
  341.              us3.un();
  342.        cout<<endl;
  343.      }
  344.            else
  345.                    break;
  346.           case 2:us3.un();
  347.      cout<<"________________________________________________________________________________"<<endl;
  348.    }
  349.    cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
  350.    cout<<"ttt     程序结束,谢谢使用!"<<endl;
  351.    break;
  352.  case 4:Ar4 us4;       
  353.    cout<<"需要加密还是解密(加密1/解密2)"<<endl;
  354.          cout<<"需要:";
  355.    cin>>a;
  356.    cout<<"________________________________________________________________________________"<<endl;
  357.    cout<<"加密解密说明:"<<endl;
  358.    cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
  359.    cout<<"________________________________________________________________________________"<<endl;
  360.    cout<<"请输入文字:"<<endl;
  361.          switch(a)
  362.    {case 1:us4.en();
  363.                  cout<<endl;
  364.      cout<<"________________________________________________________________________________"<<endl;
  365.                  cout<<"是否需要解密(1是/2否)"<<endl;
  366.      cout<<"选择:";
  367.                  cin>>b;
  368.      cout<<"________________________________________________________________________________"<<endl;
  369.            if(b==1)
  370.      {cout<<"请输入文字:"<<endl;
  371.              us4.un();
  372.        cout<<endl;
  373.      }
  374.            else
  375.                    break;
  376.           case 2:us4.un();
  377.         cout<<"________________________________________________________________________________"<<endl;
  378.    }
  379.    cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
  380.    cout<<"ttt     程序结束,谢谢使用!"<<endl;
  381.    break;
  382.  }