open officer by C.txt
上传用户:nt628733
上传日期:2022-07-18
资源大小:2k
文件大小:11k
- #include <iostream.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <string.h>
- class Ar1 //算法1
- {private:char ch;
- public:void en()
- {while(ch=getchar())
- { if ((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
- {ch=ch+7;
- if(ch>'Z'&&ch<='Z'+7||ch>'z')
- ch=ch-26;
- printf("%c",ch);
- }
- else
- if(ch!='n')
- printf("%c",ch);
- else
- break;
- }
- }
- void un()
- {while(ch=getchar())
- {if ((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
- {ch=ch-7;
- if(ch<'A'||ch>='a'-7&&ch<'a')
- ch=ch+26;
- printf("%c",ch);
- }
- else
- if(ch!='n')
- printf("%c",ch);
- else
- break;
- }
- }
- };
- class Ar2 //算法2
- {private:int i,j,k;
- char ch;
- char A[26][3];
- public:void en()
- {char A[26][3]={"Ww","Yy","Hh","Dd","Aa",
- "Oo","Ff","Uu","Ii","Mm","Ee","Rr","Vv",
- "Ll","Gg","Zz","Bb","Tt","Cc","Jj","Nn",
- "Ss","Pp","Kk","Xx","Qq"};
- while(ch=getchar())
- if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
- {for(j=0;j<2;j++)
- for(i=0;i<26;i++)
- { if(ch==A[i][j])
- { k=(i+5)%26;
- ch=A[k][j];
- printf("%c",ch);
- break;
- }
- }
- }
- else
- if(ch!='n')
- printf("%c",ch);
- else
- break;
- }
- void un()
-
- { char A[26][3]={"Jj","Mm","Zz","Dd","Aa",
- "Oo","Gg","Uu","Ee","Yy","Ii","Rr","Vv",
- "Ll","Ff","Xx","Bb","Tt","Cc","Ww","Nn",
- "Ss","Pp","Kk","Hh","Qq"};
- while(ch=getchar())
- if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
- {for(j=0;j<2;j++)
- for(i=0;i<26;i++)
- { if(ch==A[i][j])
- {i=(i+26-5)%26;
- ch=A[i][j];
- printf("%c",ch);
- break;
- }
- }
- }
- else
- if(ch!='n')
- printf("%c",ch);
- else
- break;
- }
- };
- class Ar3 //算法3
- {private:char A[200];
- char a[100][5];
- char ch;
- int i,j,k,n,m;
- public:void en()
- { k=0;m=0;
- while((ch=getchar())!='n')
- { A[k]=ch;
- k++;
- }
- if(k%5!=0)
- n=k/5+1;
- else
- n=k/5;
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- {a[i][j]=A[m];
- m++;
- if(m>k)
- a[i][j]=' ';
- }
- }
- for(i=0;i<n/2;i++)
- { for(j=0;j<5;j++)
- { ch=a[i][j];
- a[i][j]=a[n-1-i][j];
- a[n-1-i][j]=ch;
- }
- }
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- cout<<a[i][j];
- }
- }
- void un()
- { k=0;m=0;
- while((ch=getchar())!='n')
- { A[k]=ch;
- k++;
- }
- n=k/5;
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- {a[i][j]=A[m];
- m++;
- if(m>k)
- a[i][j]=' ';
- }
- }
- for(i=0;i<n/2;i++)
- { for(j=0;j<5;j++)
- { ch=a[i][j];
- a[i][j]=a[n-1-i][j];
- a[n-1-i][j]=ch;
- }
- }
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- cout<<a[i][j];
- }
- }
- };
- class Ar4 //算法4
- {private:char A[200];
- char a[100][5];
- char ch;
- int i,j,k,n,m;
- public:
- void en()
- { k=0;m=0;
- while((ch=getchar())!='n')
- { A[k]=ch;
- k++;
- }
- if(k%5!=0)
- n=k/5+1;
- else
- n=k/5;
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- {a[i][j]=A[m];
- m++;
- if(m>k)
- a[i][j]=' ';
- }
- }
- for(i=0;i<n;i++)
- { ch=a[i][1];
- a[i][1]=a[i][2];
- a[i][2]=ch;
- ch=a[i][3];
- a[i][3]=a[i][4];
- a[i][4]=ch;
- }
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- cout<<a[i][j];
- }
- }
- void un()
- { k=0;m=0;
- while((ch=getchar())!='n')
- { A[k]=ch;
- k++;
- }
- n=k/5+1;
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- {a[i][j]=A[m];
- m++;
- if(m>k)
- a[i][j]=' ';
- }
- }
- for(i=0;i<n;i++)
- { ch=a[i][1];
- a[i][1]=a[i][2];
- a[i][2]=ch;
- ch=a[i][3];
- a[i][3]=a[i][4];
- a[i][4]=ch;
- }
- for(i=0;i<n;i++)
- { for(j=0;j<5;j++)
- cout<<a[i][j];
- }
- }
- };class Va
- {private:int i;
- char pa[4];
- public:void sr()
- {char x='*';
- for(int ii=1;ii<4;ii++)
- {for(i=0;i<5;i++)
- { pa[i]=getch();
- putchar(x);
- }
- cout<<'n';
- if(pa[0]=='y'&&pa[1]=='u'&&pa[2]=='a'&&pa[3]=='n')
- {cout<<"登陆成功!"<<endl;
- cout<<"欢迎您的使用!"<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"请输入需要使用的算法(Arithmetic:1/2/3/4)"<<endl;
- break;
- }
- else
- {if(ii==3)
- {cout<<"您是非法用户!按任意键退出程序。a"<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- exit(0);
- }
- else
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"登陆口令输入错误!请重新输入:"<<endl;
- cout<<"剩余限制次数:"<<3-ii<<"次"<<endl;
- }
- }
- }
- };
- void main()
- {int a,b;
- cout<<"ttt Visual C++语言基础课程设计 "<<endl;
- cout<<"nnn";
- cout<<"请输入登陆口令:"<<endl;
- Va us;
- us.sr();
- cout<<"使用算法:";
- cin>>a;
- cout<<"________________________________________________________________________________"<<endl;
- switch(a)
- {case 1:Ar1 us1;
- cout<<"需要加密还是解密(加密1/解密2)"<<endl;
- cout<<"需要:";
- cin>>a;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"加密解密说明:"<<endl;
- cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"请输入文字:"<<endl;
- switch(a)
- {case 1:us1.en();
- cout<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"是否需要解密(1是/2否)"<<endl;
- cout<<"选择:";
- cin>>b;
- cout<<"________________________________________________________________________________"<<endl;
- if(b==1)
- {cout<<"请输入文字:"<<endl;
- us1.un();
- cout<<endl;
- }
- else
- break;
- case 2:us1.un();
- cout<<"________________________________________________________________________________"<<endl;
- }
- cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
- cout<<"ttt 程序结束,谢谢使用!"<<endl;
- break;
- case 2:Ar2 us2;
- cout<<"需要加密还是解密(加密1/解密2)"<<endl;
- cout<<"需要:";
- cin>>a;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"加密解密说明:"<<endl;
- cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"请输入文字:"<<endl;
- switch(a)
- {case 1:us2.en();
- cout<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"是否需要解密(1是/2否)"<<endl;
- cout<<"选择:";
- cin>>b;
- cout<<"________________________________________________________________________________"<<endl;
- if(b==1)
- {cout<<"请输入文字:"<<endl;
- us2.un();
- cout<<endl;
- }
- else
- break;
- case 2:us2.un();
- cout<<"________________________________________________________________________________"<<endl;
- }
- cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
- cout<<"ttt 程序结束,谢谢使用!"<<endl;
- break;
- case 3:Ar3 us3;
- cout<<"需要加密还是解密(加密1/解密2)"<<endl;
- cout<<"需要:";
- cin>>a;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"加密解密说明:"<<endl;
- cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"请输入文字:"<<endl;
- switch(a)
- {case 1:us3.en();
- cout<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"是否需要解密(1是/2否)"<<endl;
- cout<<"选择:";
- cin>>b;
- cout<<"________________________________________________________________________________"<<endl;
- if(b==1)
- {cout<<"请输入文字:"<<endl;
- us3.un();
- cout<<endl;
- }
- else
- break;
- case 2:us3.un();
- cout<<"________________________________________________________________________________"<<endl;
- }
- cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
- cout<<"ttt 程序结束,谢谢使用!"<<endl;
- break;
- case 4:Ar4 us4;
- cout<<"需要加密还是解密(加密1/解密2)"<<endl;
- cout<<"需要:";
- cin>>a;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"加密解密说明:"<<endl;
- cout<<"本程序只对英文大小写字母加密解密,数字及符号忽略不加密解密."<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"请输入文字:"<<endl;
- switch(a)
- {case 1:us4.en();
- cout<<endl;
- cout<<"________________________________________________________________________________"<<endl;
- cout<<"是否需要解密(1是/2否)"<<endl;
- cout<<"选择:";
- cin>>b;
- cout<<"________________________________________________________________________________"<<endl;
- if(b==1)
- {cout<<"请输入文字:"<<endl;
- us4.un();
- cout<<endl;
- }
- else
- break;
- case 2:us4.un();
- cout<<"________________________________________________________________________________"<<endl;
- }
- cout<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n'<<'n';
- cout<<"ttt 程序结束,谢谢使用!"<<endl;
- break;
- }
- }