头像

ACER01




在线 


最近来访(3)
用户头像
77777777777
用户头像
四合院院士

活动打卡代码 AcWing 755. 平方矩阵 III

ACER01
56分钟前
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int N[100] = {0};
    int m[100][100];
    m[0][0] = 1;
    int n;
    int i = 0;
    while(i < 100)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        else
        {
            N[i] = n;
        }
        i++;
    }
    i = 0;
    while(N[i] != 0)
    {
        for(int num = 1; num < N[i]; num++)
        {
            m[0][num] = m[0][num - 1] * 2; 
        }
        for (int j = 1; j < N[i]; j++)
        {
            for (int k = 0; k < N[i]; k++)
            {
                m[j][k] = m[j - 1][k] * 2;
            }
        }
        for (int j = 0; j < N[i]; j++)
        {
            for (int k = 0; k < N[i]; k++)
            {
                cout << m[j][k] << " ";
            }
            cout << endl;
        }
        cout << endl;
        i++;
    }
    return 0;
}


活动打卡代码 AcWing 754. 平方矩阵 II

ACER01
1小时前
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int N[100] = {0};
    int m[100][100] = {2};
    int n;
    int i = 0;
    while(i < 100)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        else
        {
            N[i] = n;
        }
        i++;
    }
    i = 0;
    while(N[i] != 0)
    {
        for (int j = 0; j < N[i]; j++)
        {
            for (int k = 0; k < j + 1; k++)
            {
                m[j][k] = abs(j - k + 1);
            }
        }
        for (int j = 0; j < N[i]; j++)
        {
            for (int k = j + 1; k < N[i]; k++)
            {
                m[j][k] = m[j][k-1] + 1;
            }
        }
        for (int j = 0; j < N[i]; j++)
        {
            for (int k = 0; k < N[i]; k++)
            {
                cout << m[j][k] << " ";
            }
            cout << endl;
        }
        cout << endl;
        i++;
    }
    return 0;
}



ACER01
1小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    double m[12][12];
    char calculate;
    double sum;
    int num = 0;
    sum = 0.0;
    cin >> calculate;
    for(int i = 0; i < 12; i++)
    {
        for(int j = 0; j < 12; j++)
        {
            cin >> m[i][j];
        }
    }
    for(int i = 7; i < 12; i++)
    {
        for(int j = 12 - i; j < i; j++)
        {

                sum += m[j][i];
                num ++;
        }
    }
      if(calculate == 'S')
    {
        printf("%0.1lf\n", sum);        
    }
    else if(calculate == 'M')
    {
        printf("%0.1lf\n", sum / num);
    }
    return 0;
}



ACER01
1小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    double m[12][12];
    char calculate;
    double sum;
    int num = 0;
    sum = 0.0;
    cin >> calculate;
    for(int i = 0; i < 12; i++)
    {
        for(int j = 0; j < 12; j++)
        {
            cin >> m[i][j];
        }
    }
    for(int i = 7; i < 12; i++)
    {
        for(int j = 12 - i; j < i; j++)
        {

                sum += m[i][j];
                num ++;
        }
    }
      if(calculate == 'S')
    {
        printf("%0.1lf\n", sum);        
    }
    else if(calculate == 'M')
    {
        printf("%0.1lf\n", sum / num);
    }
    return 0;
}



ACER01
1小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    double m[12][12];
    char calculate;
    double sum;
    int num = 0;
    sum = 0.0;
    cin >> calculate;
    for(int i = 0; i < 12; i++)
    {
        for(int j = 0; j < 12; j++)
        {
            cin >> m[i][j];
        }
    }
    for(int i = 0; i < 12; i++)
    {
        for(int j =  0; j < i; j++)
        {

                sum += m[i][j];
                num ++;
        }
    }
      if(calculate == 'S')
    {
        printf("%0.1lf\n", sum);        
    }
    else if(calculate == 'M')
    {
        printf("%0.1lf\n", sum / num);
    }
    return 0;
}



ACER01
1小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    double m[12][12];
    char calculate;
    double sum;
    int num = 0;
    sum = 0.0;
    cin >> calculate;
    for(int i = 0; i < 12; i++)
    {
        for(int j = 0; j < 12; j++)
        {
            cin >> m[i][j];
        }
    }
    for(int i = 0; i < 12; i++)
    {
        for(int j = 12 - i; j < 12; j++)
        {

                sum += m[i][j];
                num ++;
        }
    }
      if(calculate == 'S')
    {
        printf("%0.1lf\n", sum);        
    }
    else if(calculate == 'M')
    {
        printf("%0.1lf\n", sum / num);
    }
    return 0;
}


活动打卡代码 AcWing 744. 数组中的列

ACER01
1小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    double m[12][12];
    char calculate;
    int l;
    double sum;
    cin >> l >> calculate;
    sum = 0;
    for(int i = 0; i < 12; i++)
    {
        for(int j = 0; j < 12; j++)
        {
            cin >> m[i][j];
            if(j == l)
            {
                sum += m[i][j];
            }

        }
    }
   if(calculate == 'S')
    {
        printf("%0.1lf\n", sum);        
    }
    else if(calculate == 'M')
    {
        printf("%0.1lf\n", sum / 12.0);
    }
    return 0;
}



ACER01
1小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int n, position, value;
    int min;
    cin >> n;
    cin >> value;
    min = value;
    position = 0;
    for(int i = 1; i < n; i++)
    {
        cin >> value;
        if (value < min)
        {
            position = i;
            min = value;
        }
    }
    cout << "Minimum value: " << min << endl;
    cout << "Position: " << position << endl;
    return 0;
}


活动打卡代码 AcWing 741. 斐波那契数列

ACER01
2小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int n,num;
    long long int N[60];
    N[0] = 0;
    N[1] = 1;
    cin >> n;
    for (int i = 0 ; i < n; i++)
    {
        cin >> num;
        if (num == 0)
        {
            cout << "Fib(0) = 0" << endl;
        }
        else if(num == 1)
        {
            cout << "Fib(1) = 1" << endl;
        }
        else
        {
            for (int j = 1; j < num; j++)
            {
                N[j + 1] = N[j] + N[j-1]; 
            }
            printf("Fib(%d) = %lld\n", num, N[num]);
        }
    }
    return 0;
}


活动打卡代码 AcWing 740. 数组变换

ACER01
2小时前
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int n[20];
    for (int i = 1;i <= 20; i++)
    {
        cin >> n[20- i];
    }
    for (int i = 0; i < 20; i++)
    {
        printf("N[%d] = %d\n", i, n[i]);
    }
    return 0;
}