2 条题解

  • 0
    @ 2025-11-23 15:14:02

    cpp

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
    	char a[10005],b[10005];
    	cin.getline(a,10005);
    	cin.getline(b,10005);
    	int la= strlen(a);
    	int lb= strlen(b);
    	for(int i = 0; i < la;i ++){
    		if(a[i] >= 'A' && a[i]<= 'Z'){
    			a[i] += 32;
    		}
    	}
    	for(int i = 0; i < lb;i ++){
    		if(b[i] >= 'A' && b[i]<= 'Z'){
    			b[i] += 32;
    		}
    	}
    	int c= strcmp(a,b);
    	if(c == 0){
    		cout << '=';	
    	}
    	if(c > 0){
    		cout << '>';	
    	}
    	if(c < 0){
    		cout << '<';	
    	}
    }
    • 0
      @ 2023-12-30 21:38:31
      #include <iostream>
      #include <cstring> 
      using namespace std;
      //转换大小写
      void strupr(string &a){
      	for(int i = 0;i < a.size();i++){
      		if(a[i] >= 'a' && a[i] <= 'z'){
      			a[i] = a[i] - 'a' + 'A';
      		}
      	}
      }
      int main(){
      	string a, b;        // string变量a, b
      	getline(cin, a);
      	getline(cin, b);    // 输入a, b
      	strupr(a); 
      	strupr(b);    // 将两个字符串都设成大写
      	if(strcmp(a.c_str(), b.c_str()) > 0){  // c_str用来将string转换为字符数组,再通过strcmp比较大小
      		putchar('>');
      	}
      	else if(strcmp(a.c_str(), b.c_str()) < 0){
      		putchar('<');
      	}
      	else{
      		putchar('=');
      	}
      	return 0;
      }
      
      • 1

      信息

      ID
      1105
      时间
      1000ms
      内存
      128MiB
      难度
      8
      标签
      递交数
      14
      已通过
      8
      上传者