CÖÐÔõôÅжÏÒ»¸ö×Ö·ûÖÐÓм¸¸ö0ºÍ¼¸¸ö1£¿
CÖÐÔõôÅжÏÒ»¸ö×Ö·ûÖÐÓм¸¸ö0ºÍ¼¸¸ö1£¿ Êǵ¥¸ö×Ö·û£¬²»ÊÇ×Ö·û´®
ÓÃλÔËËã·ûѽ
ÁíÍ⣬½«Ê®½øÖÆÊýת»»³É2½øÖƵĹý³ÌÓ¦¸ÃÒ²¿ÉÒÔÅжϳöÀ´
Ñ»·ÓÒÒÆ£¬°ÑĩλbitÖµÓë1 Óëһϣ¬Í³¼ÆÒ»ÏÂ
C/C++ code:
int bitsof0 (unsigned char ch)
{
int res=0,pos;
for(int pos=0;pos<8;++pos)
if(ch & (0<<pos))
res++;
return res;
}
int bitsof1 (unsigned char ch)
{
return 8-bitsof0(ch);
};
C/C++ code:
#include <stdio.h>
int main()
{
char ch;
int count1=0,count0=0;
scanf("%c",&ch);
for(int i=0;i<8;i++) // charÊÇ8λµÄ
{
if((ch && 0x01)==1)
{
count1++;
}
else
{
count0++;
}
ch=ch>>1;
}
printf("×Ö·û%cº¬ÓÐ%d¸ö1£¬%d¸ö0",ch,count1,count0);
return 0;
}
C/C++ code:
#include <stdio.h>
int main(){
char c;
int i = 0;
scanf("%c",&c);
while(c){
if(c%2)
i++;
c = c/2;
}
printf("×Ö·û %cÖУ¬¹²ÓÐ %d¸ö1£¬%d¸ö0.\n&
Ïà¹ØÎÊ´ð£º
ÎÊһϣº
#include <stdio.h>
int main()
{
char x, y, z;
int i;
int a[16];
for(i=0; i<=16; i++)
{
a[i] = 0;
......
×î½üÔÚ¿´Ò»¸öÓÃbisonʵÏÖµÄC parser,OSÊÇopensolaris¡£µ±ÓÃËüÀ´½âÎöÒ»¸ö¼òµ¥µÄhello.cʱ£¬³öÏÖ¡°/usr/include/sys/va_list.h: parse error before __gnuc_va_list¡±¡£´ò¿ªÎļþva_list.hºó·¢ÏÖÕâÑùÒ»ÐС°typedef __bu ......
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
#include "stdio.h"
int main()
{
char *ch(char *, char *);
char str1[]="I am glad to meet you!";
char str2[]="Welcom to study C!";
&nb ......
ÒÔÏ·ÖÎö»ùÓÚ£º
Developer Platform :S60 3rd Edition, Feature Pack 2 SDK
Operating System :Symbian OS v9.3
Ò»£¬ÎªÊ²Ã´ÒªÊ¹ÓÃClient/Server¼Ü¹¹
ÔÚSymibian OSÖÐËùÓеÄÒì²½·þÎñ¶¼ÊÇServerͨ¹ýC/S¼Ü¹¹À´ÊµÏÖµ ......