5 条题解

  • 1
    @ 2024-12-22 11:03:52

    C :

    #include <stdio.h>
    int main(){
        char x,y;   
        x=getchar();  //输入字母,并且赋给x
        if(65<=x && x<=90){  //大写字母ASCII码范围为:65A~90Z,判断为大写执行代码
            y=x+32;  //A为65,a为97相差32,加32变为小写
            putchar(y);  //输出获得的小写字母
            putchar('\n');  //换行
        }
        else if(97<=x && x<=122){  //小写字母ASCII码范围为:97a~122z,判断为小写执行代码
            y=x-32;  //A为65,a为97相差32,减32变为大写
            putchar(y);  //输出获得的大写字母
            putchar('\n');  //换行
        }
        else{
            printf("输入有误!");  //输出提示语句,提醒输入错误
        }
    return 0;
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    
    char ch;
    int main(){
    	//freopen("change.in","r",stdin);
    	//freopen("change.out","w",stdout);
    	cin >> ch;
    	if (ch>='A'&&ch<='Z'){
    		cout << (char)(ch+32);
    	}
    	if (ch>='a'&&ch<='z'){
    		cout << (char)(ch-32);
    	}
    	return 0;
    }
    

    Python :

    # coding=utf-8
    da=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
    xi=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    a=input()
    for i in range(0,26):
        if(a==da[i]):
            print(xi[i])
            break
        if(a==xi[i]):
            print(da[i])
            break
    
    • 0
      @ 2025-1-5 9:28:29

      一道可以把人淹死的水题

      #include<bits/stdc++.h>
      using namespace std;int main(){char a;cin>>a;if(a>='A'&&a<='Z') a+=32;else a-=32;cout<<a;return 0;}
      
      • 0
        @ 2024-12-22 18:53:02

        water 题,判断下输入进去的是大写还是小写就完了。

        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
        	char a;
        	cin>>a;
        	if(a>='A'&&a<='Z')
        	{
        		a+=32;
        	}
        	else
        	{
        		a-=32;
        	}
        	cout<<a;
        	return 0;
        }
        
        • 0
          @ 2024-12-22 11:22:51

          因为只有字母,那么大于'a'的都是小写字母。

          #include<bits/stdc++.h>
          #define int long long
          #define INF 0x3f3f3f
          using namespace std;
          char c;
          signed main(){
          	cin>>c;
          	if(c>='a')cout<<char(c-32);
          	else cout<<char(c+32);
          	return 0;
          }
          
          • 0
            @ 2024-12-22 11:11:42
            #include<bits/stdc++.h>
            using namespace std;
            signed main(){
            	char c;
            	cin>>c;
            	if(islower(c))//如果是小写
                  cout<<char(c-32);//转大写
            	else cout<<char(c+32);//否则转小写
            }
            
            • 1

            信息

            ID
            8
            时间
            1000ms
            内存
            128MiB
            难度
            7
            标签
            (无)
            递交数
            245
            已通过
            56
            上传者