头像

Nazarena




离线:5小时前



Nazarena
7小时前

C++ 代码

#include<iostream>
using namespace std;

int main()
{
    int a[100][100];
    int n,m;
    cin >> m >> n;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
            cin >> a[i][j];

    for(int i=0;i<n;i++)
    {
        for(int j=m-1;j>=0;j--)
        {
            cout << a[j][i] << " ";
        }
        cout << endl;
    }       

    return 0;
} 



C++ 代码

#include <iostream>
#include <string.h>
using namespace std;

string change(string num)
{
    int sum = 0;
    if(num.length() == 1) return num;
    for (int i = 0; i < num.length(); ++i)
        sum += stoi(num.substr(i,1));
    return (change(to_string(sum)));
}

int main()
{
    string num;
    cin >> num;
    cout << change(num);
}



C++ 代码

#include<iostream>
using namespace std;

int judge(char a, char b, char c)
{
    if(a == 'J') //1,6,7
    {
        if(b == 'a')
            return 1;
        else
        {
            if(c == 'n')
                return 6;
            else 
                return 7;
        }
    }
    else if(a == 'F')
        return 2;
    else if(a == 'M') //3,5
    {
        if(c == 'r')
            return 3;
        else 
            return 5;
    }
    else if(a == 'A')  //4,8
    {
        if(b == 'p')
            return 4;
        else 
            return 8;
    }
    else if(a == 'S')
        return 9;
    else if(a == 'O')
        return 10;
    else if(a == 'N')
        return 11;
    else 
        return 12;
}

int main()
{
    string s;
    int m,d,t;
    cin >> s;
    m = judge(s[0],s[1],s[2]);
    if(s[3] - '0' == 0)
        d = s[4] - '0';
    else
        d = (s[3] - '0') * 10 + s[4] - '0';

    cout << m << " " << d;
    return 0;
}



C++ 代码

#include<iostream>
#include<algorithm>
using namespace std;

int arr[1000001];

int judge(int min, int max)
{
    if(min > max)
    {
        int t = max;
        max = min;
        min = t;
    }
    while(max % min != 0)
    {
        long long res  = max % min;
        max = min;
        min = res;
    }
    return min;
}

int main()
{
    int n;
    int d,t,len = 0;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> arr[i];
    sort(arr, arr+n);
    d = arr[1] - arr[0];
    if(d == 0)
    {
        cout << n;
        return 0;
    }
    for(int i=2;i<n;i++)
    {
        d = judge(d, arr[i]-arr[i-1]);
    }
    for(int i=1;i<n;i++)
    {
        t = arr[i] - arr[i-1];
        len = len + t / d - 1;
    }
    len += n;
    cout << len;
    return 0;
}



C++ 代码

#include<iostream>
#include<algorithm>
using namespace std;

long long judge(long long min, long long max)
{
    while(max % min != 0)
    {
        long long res  = max % min;
        max = min;
        min = res;
    }
    return min;
}

int main()
{
    int n,m = 0;
    long long arr[100],res[2][100];
    long long a,b,t;    //a分子,b分母 
    long long product = 1;
    long long am,bm;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> arr[i];
    sort(arr, arr + n);
    for(int i=1;i<n;i++)
    {
        a = arr[i-1];   //a小数,b大数 
        b = arr[i];
        if(a != b)
        {
            t = judge(a,b);
            res[1][m] = a / t;
            res[0][m] = b / t;
            m++;
        }
    }
    for(int i=0;i<m;i++)
        product *= res[1][i];
    for(int i=0;i<m;i++)
        res[0][i] = res[0][i] * product;

    am = res[1][0];
    bm = res[0][0];
    for(int i=1;i<m;i++)
    {
        if(res[0][i]<bm)
        {
            am = res[1][i];
            bm = res[0][i];
        }
    }
    bm /= product;
    cout << bm << "/" << am;
    return 0;
}



C++ 代码

#include<iostream>
using namespace std;

int main()
{
    int n,sum=0;
    cin >> n;
    sum += n;
    while(n >= 3)
    {
        n -= 2;
        sum++;
    }
    cout << sum;
    return 0;
} 



C++ 代码

#include<iostream>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    while(n>0)
    {
        cout << n << " ";
        n = n / 2; 
    }
    return 0;
}



C++ 代码

#include<iostream>
#include<string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i] >= '1' && s[i] <= '9')
        {
            int j = s[i] - '0';
            for(int k=0;k<j-1;k++)
                cout << s[i-1];
        }
        else
        {
            cout << s[i] <<"";
        }
    }
    return 0;
}



C++ 代码

```

include[HTML_REMOVED]

using namespace std;

int main()
{
int n,t,a,result=0;
cin >> n;
for(int i=1;i<=n;i++)
{
t = i;
while(t)
{
a = t % 10;
if(a==1 || a==0 || a==2 || a==9)
{
result += i;
break;
}
t = t / 10;
}
}
cout << result << “”;
return 0;
}```




C++ 代码

#include<iostream>
#include<vector>
using namespace std;

int main()
{
    vector <int> arr;
    int n,m,step;
    int sum = 0,t = 1;
    cin >> n >> m;
    step = n < m ? n : m;
    arr.push_back(1);//0
    //cout << step << endl;
    //cout << arr.size() << endl;
    while(sum < step)
    {
        if(t >= n && arr[t-n] == 1)
        {
            arr.push_back(1);
            sum++;
        }
        else if(t >= m && arr[t-m] == 1)
        {
            arr.push_back(1);
            sum++;
        }
        else
        {
            arr.push_back(0);
            sum = 0;
        }
        t++;
    }
    cout << arr.size() - step - 1 << "";
    return 0;
}