Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这个C语言代码不可以 ?

Posted by Lemke at 2009-02-27 13:48:11 on Problem 2453
#include "stdio.h"
#include "conio.h"
#define maxsize 20
int Sumbin(int x)
{
    int k,sum=0;
    while(x)
    {
        k=x%2;
        if(k==1)
        {
            sum++;
        }
        x=x/2;
    }
    return(sum);
}
main()
{
    int data[maxsize],databin[maxsize];
    int i=0,k=0,temp=1;
    while(temp)
    {   scanf("%d",&temp);
        data[k]=temp;
        databin[k]=Sumbin(data[k]);
        k++;
    }
    for(i=0;i<k-1;i++)
    {
        do{
            data[i]++;
        }while(databin[i]!= Sumbin(data[i]));
        printf("%d\n",data[i]);
    }

}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator