3 条题解

  • 1
    @ 2023-05-13 07:58:41
    #include<bits/stdc++.h>
    using namespace std;
    struct st
    {
        int zheng,fan;
    }a[105];
    int x,y,l=1;
    bool cp(st a,st b)
    {
        return a.fan<b.fan;
    }
    int main()
    {
        cin>>x>>y;
        int n=y-x+1;
        for(int i=x;i<=y;i++)
        {
            a[l].zheng=i;
            int it=i;
            while(it)
            {
                a[l].fan=a[l].fan*10+it%10;
                it/=10;
            }
            l++;
        }
        sort(a+1,a+n+1,cp);
        for(int i=1;i<=n;i++)
            cout<<a[i].zheng<<endl;
        return 0;
    }
    
    • @ 2023-05-19 20:51:49
      //还可以这样
      #include<bits/stdc++.h>
      using namespace std;
      int a[105],b[105],n;
      int main()
      {
          int x,y;cin>>x>>y;
          for(int i=x;i<=y;i++)//一个小优化 
          {
              a[++n]=i;
              int it=i;
              while(it)
              {
                  b[n]=b[n]*10+it%10;
                  it/=10;
              }
          }
          for(int i=1;i<n;i++)
              for(int j=i+1;j<=n;j++)
              {
                  if(b[i]>b[j])
                  {
                      swap(a[i],a[j]);
                      swap(b[i],b[j]);
                  }
              }
          for(int i=1;i<=n;i++)
              cout<<a[i]<<endl;
          return 0;
      }
      
  • 0

    #pragma GCC optimize(2)
    #pragma GCC optimize(3)
    #include <cstdio>
    #include <vector>
    #include <cstring>
    #include <iostream>
    #include <algorithm>

    using namespace std;

    vector<int> a;
    int n, m;

    int goback(int x)
    {
    int res = 0;
    while ( x ) res = res * 10 + x % 10, x /= 10;
    return res;
    }

    void qusort(int l, int r)
    {
    int num = a.size();
    for ( int i = 0; i < num - 1; i ++ )
    for ( int j = i + 1; j < num; j ++ )
    if ( goback(a[i]) > goback(a[j]) ) swap(a[i], a[j]);
    }

    int main()
    {
    scanf("%d%d", &n, &m);
    for ( int i = n; i <= m; i ++ ) a.push_back(i);

    qusort(0, n - m + 1);

    for_each(a.begin(), a.end(), { printf("%d\n", x);});

    return 0;
    }

  • 0
    @ 2021-11-01 21:35:29
    #pragma GCC optimize(2)
    #pragma GCC optimize(3)
    #include <cstdio>
    #include <vector>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    
    using namespace std;
    
    vector<int> a;
    int n, m;
    
    int goback(int x)
    {
        int res = 0;
        while ( x ) res = res * 10 + x % 10, x /= 10;
        return res;
    }
    
    void qusort(int l, int r)
    {
        int num = a.size();
        for ( int i = 0; i < num - 1; i ++ )
            for ( int j = i + 1; j < num; j ++ )
                if ( goback(a[i]) > goback(a[j]) ) swap(a[i], a[j]);
    }
    
    int main()
    {
        scanf("%d%d", &n, &m);
        for ( int i = n; i <= m; i ++ ) a.push_back(i);
        
        qusort(0, n - m + 1);
        
        for_each(a.begin(), a.end(), [](int x){ printf("%d\n", x);});
        
        
        return 0;
    }
    
  • 1

信息

ID
2424
难度
4
分类
(无)
标签
递交数
79
已通过
33
通过率
42%
被复制
5
上传者