チェック7-19のタイトル基本的なプログラミング電流量(15分)

ここに画像を挿入説明

#include <cstdio>
#include <iostream>
using namespace std;
int y, f, n;
int main()
{
    scanf("%d", &n);
    y = (98 - n) / 3;
    f = 2 * y + 1;
    if ((98 - n) % 3 == 0)
        printf("%d.%d\n", y, f);
    else
    {
        for (int i = 0; i < 100; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                if ((2 * i * 100 + 2 * j) == (j * 100 + i - n))
                {
                    printf("%d.%d\n", i, j);
                    return 0;
                }
            }
        }
        printf("No Solution\n");
    }

    return 0;
}
公開された287元の記事 ウォンの賞賛117 ビュー8933

おすすめ

転載: blog.csdn.net/qq_44458489/article/details/105400001