标题:大神们,求指教。。。为什么会打印两个。
取消只看楼主
花开落未央
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-3-4
 问题点数:0 回复次数:1 
大神们,求指教。。。为什么会打印两个。
#include<stdio.h>
int F(int a)
{
    int i,b=0,p=0;
    for(i=1;i<a;i++)
        if(a%i==0)
            b=b+i;
        for(i=1;i<b;i++)
            if(b%i==0)
                p=p+i;
               if(p==a&&a<b)
            {
                printf("%d<->%d\n",a,b);
               
                    return 0;
               }
               else
                   return 1;
}
int main()
{
    int i,lBound,uBound,t=0;
    scanf("%d%d",&lBound,&uBound);
   
    for(i=lBound;i<=uBound;i++ )
    {
        F(i);
        if(F(i)==1)
            t++;
        
    }
    if(t==uBound-lBound+1)
        printf("No intimate numbers");
    return 0;
}
搜索更多相关主题的帖子: include return 
2014-05-08 20:37
花开落未央
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-3-4
得分:0 
回复 2 楼 top398
寻找2个数之间的亲密对数。没有的话输出‘No inti.......’.
2014-05-14 08:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-431226-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.372568 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved