编写一个译码程序,编码规律:将字母a变成字母f,即变成其后的第四个字母,x变成b,y变成c,z变成d.

来源:百度知道 编辑:UC知道 时间:2024/06/15 03:06:54
用C++语言编写该程序

#include<iostream.h>
#include<stdio.h>
void main(){
char a[100];
gets(a);
int i=0;
while(a[i]!='\0'){
if(a[i]<'v')
cout<<char((a[i]+5));
else
cout<<char((a[i]-('v'-'a')));
i++;
}
cout<<endl;
}

import java.io.*;

public class TwoThreadsTest{

public static void main(String args[]) {
byte[] b= new byte[1];
try {
System.in.read(b);
if(b[0]>=97&&b[0]<=120) System.out.println((char)(b[0]+4));
else if(b[0]>120&&b[0]<=123) System.out.println((char)(b[0]-22));
} catch (IOException e) {
e.printStackTrace();
}
}
}

input a,x,y,z
f=a
b=x
c=y
d=z
print f,b,c,d
ind