1 条题解
-
0
C :
#include <stdio.h> #include <ctype.h> int main(){ int m,n,i,j; char s[101]; scanf("%d%*c",&n); while(n--){ i=0; gets(s); while(s[i]){ if(s[i]<='Z') s[i] = tolower(s[i]); else s[i] = toupper(s[i]); i++; } puts(s); } return 0; }
C++ :
#include<iostream> #include<string> #include<cctype> using namespace std; int main(){ int n; cin>>n; while(n--){ string s; cin>>s; for(string::size_type ix=0;ix<s.size();ix++){ if(s[ix]>='A'&& s[ix]<='Z') s[ix]=tolower(s[ix]); else s[ix]=toupper(s[ix]); } for(string::size_type i=0;i<s.size();i++) cout<<s[i]; cout<<endl; } }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int m=sc.nextInt(); while(m-->0){ String str=sc.next(); char c[]=str.toCharArray(); for(int i=0;i<c.length;i++){ if(Character.isLowerCase(c[i])){ System.out.print(Character.toUpperCase(c[i])); }else if(Character.isUpperCase(c[i])){ System.out.print(Character.toLowerCase(c[i])); } } System.out.println(); } sc.close(); } }
Python :
# coding=utf-8 b=int(input()) for i in range(0,b,1): a=input() print( a.swapcase() )
- 1
信息
- ID
- 224
- 时间
- 3000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 2
- 已通过
- 1
- 上传者