头像

MetaInsight




离线:5天前


最近来访(2)
用户头像
yxc的小迷妹

活动打卡代码 AcWing 718. 实验

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

int main()
{
    int n;
    double sum_c=0,sum_r=0,sum_f=0;
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        double a;
        string b;
        cin >> a >> b;
        if (b=="C") sum_c += a;
        else if (b=="R") sum_r += a;
        else if (b=="F") sum_f += a;
    }
    printf("Total: %.lf animals\n",sum_f+sum_r+sum_c);
    printf("Total coneys: %.lf\n",sum_c);
    printf("Total rats: %.lf\n",sum_r);
    printf("Total frogs: %.lf\n",sum_f);
    printf("Percentage of coneys: %.2lf %\n",sum_c/(sum_f+sum_r+sum_c)*100);
    printf("Percentage of rats: %.2lf %\n",sum_r/(sum_f+sum_r+sum_c)*100);
    printf("Percentage of frogs: %.2lf %\n",sum_f/(sum_f+sum_r+sum_c)*100);
}


活动打卡代码 AcWing 711. 乘法表

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

int main()
{
    int n,i=1;
    cin >> n;
    while (i<=10)
    {
        printf("%d x %d = %d\n",i,n,i*n);
        i++;
    }
}


活动打卡代码 AcWing 710. 六个奇数

#include <iostream>
using namespace std;
int main()
{
    int x;
    cin >> x;
    for (int i=0;i<=11;i++)
    {
        if ((x+i)%2!=0) cout << x+i << endl;
    }

    return 0;
}


活动打卡代码 AcWing 715. 余数

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    for (int i=2;i<10000;i++)
    {
        if (i%n==2) cout << i << endl;
    }
    return 0;
}


活动打卡代码 AcWing 723. PUM

#include <iostream>
using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    for (int i=1,k=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++,k++)
        {
            if (k%m==0) cout << "PUM";
            else
                cout << k <<' ';
        }
        cout << endl;
    }
}


活动打卡代码 AcWing 724. 约数

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;

    for (int i=1;i<=n;i++){
        if (n%i==0) cout << i << endl;
    }
}


活动打卡代码 AcWing 720. 连续整数相加

#include <iostream>
using namespace std;

int main()
{
    int a,n,sum=0;
    cin >> a;

    while (true){
        cin >> n;
        if (n>0){
            for (int i=1,k=a;i<=n;i++,k++){
                sum = sum +k;
            }
            cout << sum;
            break;
        }

    }
}


活动打卡代码 AcWing 721. 递增序列

#include <iostream>

using namespace std;

int main()
{
    while (1){
        int x;
        cin >> x;

        if (x!=0){
             for (int i=1;i<=x;i++){
                 cout << i << ' ';

             }
             cout << endl;
        }
        else
            break;
    }




}



python

num_list = []
for i in range(1,101):
    num = int(input())
    num_list.append(num)
print(max(num_list))
print(num_list.index(max(num_list))+1)




#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int a, b,sum,i;
    cin >> a >> b;
    sum=0;
    i = min(a,b)+1;
    while (i<max(a,b)){
        if (i%2!=0)  sum+=i;
        i++;
    }
    cout << sum;
}