1 条题解
-
0
C :
#include<stdio.h> int main(){ char c; while((c=getchar())!='\n'){ if(c>='A'&&c<='Z' || c>='a'&&c<='z'){ if(c>='W'&&c<='Z' || c>='w'&&c<='z') c=c-26+4; else c=c+4; } printf("%c",c); } printf("\n"); return 0; }
C++ :
#include <stdio.h> #include <math.h> int main() { char c; while ((c = getchar()) != '\n') { if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) { c = c + 4; if (c > 'Z' && c <= 'Z' + 4 || c > 'z') c = c - 26; } printf("%c", c); } printf("\n"); return 0; }
Pascal :
var i:longint; s,sa:string; c:char; function turn(c:char):char; var ch:char; begin ch:=upcase(c); ch:=chr( (ord(ch)-ord('A')+4) mod 26 + ord('A') ); if(upcase(c)=c) then exit(ch) else exit(lowercase(ch)); end; begin readln(s); sa:=''; for i:=1 to length(s) do begin c:=upcase(s[i]); if( c in ['A'..'Z'] ) then sa:=sa+turn(s[i]) else sa:=sa+s[i]; end; writeln(sa); end.
Java :
import java.util.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(System.in); String s = cin.nextLine(); char[] c = s.toCharArray(); for(int i=0;i<c.length;i++){ if((c[i]>='A' && c[i]<='Z')||(c[i]>='a' && c[i]<='z')) { c[i]+=4; if((c[i]>'Z'&&c[i]<'a')||c[i]>'z') c[i]-=26; } } System.out.println(new String(c)); } }
Python :
from string import maketrans table = maketrans('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'efghijklmnopqrstuvwxyzabcdEFGHIJKLMNOPQRSTUVWXYZABCD') print raw_input().translate(table)
- 1
信息
- ID
- 1273
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者