7-218 数完数个数7-219 sdut-C语言实验-A+B for Input-Output Practice (不确定次数循环)

目录

7-218 数完数个数

7-219 sdut-C语言实验-A+B for Input-Output Practice (不确定次数循环)


7-218 数完数个数

分数 10

全屏浏览题目

切换布局

作者 C课程组-ty

单位 湖南工程学院

一个正整数的真因子是指所有能整除它的正整数(不包括自身)。

一个正整数的所有真因子之和等于其本身则被称为完数。

例如:6=1+2+3,6是完数;

而9不是,1也不是。

求在[m,n]之间的完数的个数。

输入格式:

在一行中输入m和n的值,保证m<=n,并且都是正整数(读者无需考虑)。

输出格式:

在一行中输出个数。

输入样例1:

5   30

输出样例1:

2

输入样例2:

2   5

输出样例2:

0
#include <stdio.h>

int main(){
    int num=0;
    int f[999];
    int n;
    int m;
    int c=0;
    scanf("%d",&m);
    scanf("%d",&n);
    for (int i = m; i <= n; ++i) {
        int index = 0;
        int temp = 0;
        for (int j = 1; j <= i/2; ++j) {
            if(i%j==0){
                f[index] = j;
                temp += j;
                num++;
                index++;
            }
        }

        if(temp == i){
//            printf("%d\n",i);
            c++;
        }

        num = 0;
    }
    printf("%d",c);
    return 0;
}

 

7-219 sdut-C语言实验-A+B for Input-Output Practice (不确定次数循环)

分数 10

全屏浏览题目

切换布局

作者 马新娟

单位 山东理工大学

Your task is to Calculate a + b.

Too easy?! Of course! I specially designed the problem for acm beginners.

You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.

输入格式:

The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.

输出格式:

For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.

输入样例:

1 5
10 20

输出样例:

在这里给出相应的输出。例如:

6
30

 

#include "stdio.h"
int a,b;
int main()
{
    while(scanf("%d%d",&a,&b)!= EOF)
    {
    printf("%d\n",a+b);
    }
}

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小羊 : )

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值