1.输入一个小写字母,输出其大写格式
#include <iostream>
using namespace std;
int main(){
char c;
cin>>c;
c = c - 'a' + 'A';
cout<<c;
}
3.输入一个大写字母,输出其小写格式
#include <iostream>
using namespace std;
int main(){
char c;
cin>>c;
c = c - 'A' + 'a';
cout<<c;
}
Java
package com.su;
public class demo {
public static void main(String[] args) throws Exception{
char c = 'A';
System.out.println((char)(c + 32));
System.out.println(Character.toLowerCase(c));
}
}