1:
#include "stdio.h"
void encrypt(char ch[],char chp[])
{
for(int i=0;ch[i]>0;i++)
{
if(ch[i]>='A'&ch[i]<='Z')
chp[i]='A'+(ch[i]-'A'+4)%26;
else if(ch[i]>='a'&ch[i]<='z')
chp[i]='a'+(ch[i]-'a'+4)%26;
else
chp[i]=ch[i];
}
}
void decode(char chp[],char ch[])
{
for(int i=0;chp[i]>0;i++)
{
if(chp[i]>='A'&chp[i]<='Z')
ch[i]='A'+(chp[i]-'A'+22)%26;
else if(chp[i]>='a'&chp[i]<='z')
ch[i]='a'+(chp[i]-'a'+22)%26;
else
ch[i]=chp[i];
}
}
void initialize(char ch[],char chp[],int n ,int m)
{
for(int i=0;i
for(int i=0;i
}
void main()
{
int m=1;
while(m)
{
char ch[100],chp[100];
char sel;
initialize(ch,chp,100,100);
printf("选择加密或解密:1 加密,2 解密,Other Key for 退出\n");
scanf("%c",&sel);
if(sel=='1')
{
printf("加密程序,输入原文:");
scanf("%s",ch);
encrypt(ch,chp);
printf("生成的密文:");
for(int i=0;chp[i]>0;i++)
printf("%c",chp[i]);
printf("\n");
getchar();
}
else if(sel=='2')
{
printf("解密程序,输入密文:");
scanf("%s",chp);
decode(chp,ch);
printf("生成的原文:");
for(int i=0;ch[i]>0;i++)
printf("%c",ch[i]);
printf("\n");
getchar();
}
else
m=0;
}
}
# include
# include
void main()
{
char s[5],snew[5];
int i;
cout<<"Please input the string:"<
{
cin>>s[i];
}
for( i=0;i<5;i++)
{
snew[i]=s[i]-32;
}
cout<<"The jiami hou de string:"<
{
cout<
}
//一元二次方程的解
# include
# include
void main(void)
{
float temp,s;
float a,b,c;
cout<<"please input a b c:"<
temp=b*b-4*a*c;
if(temp>=0)
s=sqrt(temp);
else
cout<<"The question doesnot have a real answer!"<
float x1=(-b+s)/2*a;
float x2=(-b-s)/2*a;
cout<<"x1="<
}
//运用函数求解阶乘
#include
int fac(int n)
{
int sum=1;
for(int i=1;i<=n;i++)
{
sum*=i;
}
return sum;
}
void main(void)
{
int a,b,c,s;
cout<<"Please input the a b c:"<
s=fac(a)+fac(b)+fac(c);
cout<<"the result is :";
cout<<"s="<
}
给你随便写了三个!