3 条题解

  • 1
    @ 2025-8-25 22:28:46
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int x,y,z;
        scanf("%d,%d,%d",&x,&y,&z);
        int nums[3]={x,y,z};
        std::sort(nums,nums+3);
        printf("%d %d %d",nums[0],nums[1],nums[2]);
        return 0;
    }
    
    • 0
      @ 2025-8-1 13:19:17
      #include<iostream>
      #include<string>
      #include <sstream>
      using namespace std;
      //暴力完成版
      int main(){
          int x,y,z;
          string num;
          getline(cin,num); 
          istringstream word(num);
          char comma1,comma2; 
          if (word >> x >> comma1 >> y >> comma2 >> z){
          	//比大小功能实现部分;
      	    if (x>y){
      	        if(x>z){
      	            if(y>z){
      	                cout<<z<<" "<<y<<" "<<x;
      	            }
      	            else{
      	                cout<<y<<" "<<z<<" "<<x;
      	            }
      	        }
      	        else{
      	            cout<<y<<" "<<x<<" "<<z;
      	        }
      	    }
      	    else{
      	        if(y>z){
      	            if(z>x){
      	                cout<<x<<" "<<z<<" "<<y;
      	            }
      	            else{
      	                cout<<z<<" "<<x<<" "<<y;
      	            }
      	        }
      	        else{
      	            cout<<x<<" "<<y<<" "<<z;
      	        }
      	    }
      	}else {
              cerr << "输入格式错误,请确保输入三个用逗号分隔的整数!" << endl;
          }
          return 0;
      }
      
      
      • 0
        @ 2024-5-31 23:07:19
        #include <iostream>
        #include <algorithm>
        #include <vector>
        using namespace std;
        
        int main() {
            string s;
            cin >> s;
            vector<int> a; // 使用动态数组存储数字
            string t;
        
            for (int i = 0; i < s.length(); i++) {
                if (s[i] != ',') {
                    t += s[i]; 
                } else {
                    if (!t.empty()) { 
                        a.push_back(stoi(t));
                        t.clear(); 
                    }
                }
            }
            if (!t.empty()) {
                a.push_back(stoi(t));
            }
        
            sort(a.begin(), a.end()); 
        
            for (int num : a) {
                cout << num << " ";
            }
            return 0;
        }
        
        • 1

        信息

        ID
        289
        时间
        1000ms
        内存
        128MiB
        难度
        6
        标签
        递交数
        963
        已通过
        284
        上传者