目录
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);
}
}