磕代码:cc++java:输入两行大写字母,输出小写字母;用while循环检测输入

tech2022-10-21  104

c:

#include<stdio.h> int main() { char a; while(scanf("%c",&a)!=EOF){//EOF每一行结束的标志 getchar();//吞掉回车键 printf("%c\n",a+32); } }

c++:

#include<bits/stdc++.h> using namespace std; int main(){ char a,b; //cin>>(int)a>>(int)b; //a=a+32; //b=b+32; //cout<<a<<"\n"<<b; while(cin>>a){ cout<<char(a+32)<<endl; //cout换行用endl; } }

Java:

import java.io.*; public class Main{ public static void main(String[]args)throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); //String a=String // String str=null; String a; while((a=br.readLine())!=null){ //System.out.printf("%c",a+32); System.out.println(a.toLowerCase()); } //char b=s.charAt(1); //char的读取:https://blog.csdn.net/marcotsui/article/details/108139975 } } //a.toLowerCase();null;while循环检测输入,不用两次都考虑
最新回复(0)