ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

یه سوال بدون جواب منطقی

 
Post new topic   Reply to topic    ParsX.com Forum Index -> اخبار و مباحث عمومي
View previous topic :: View next topic  
Author Message
arash
مدير بخش سي
مدير بخش سي


Joined: 27 Nov 2004
Posts: 1232
Location: www.parsx.com

PostPosted: Thu Apr 13, 2006 5:32 pm    Post subject: یه سوال بدون جواب منطقی Reply with quote

یکی از دوستان گفت یه برنامه بنویسم که یک عدد باینری بگیره و بعد کاراکتر معدلش رو چاپ کنه مثلا اگه عدد 1000001 رو وارد کنید اول اون رو به 65 تبدیل کنه بعد کاراکتر A رو چاپ کنه. وقتی برنامه رو نوشتم درست کار می کرد ولی ...
ولیش انجاست که بعد با اعداد دیگه چکش کردم یعنی به جای عدد باینری عدد 65 رو زدم و در کمال تعجب دید که برنامه درست کار می کنه و کاراکتر A رو چاپ می کنه می شه یکی این موضوع رو توضیح بده ؟ چون می گن کامپیوتر یه دستگاه منطقیه ولی این کاملا غیر منطقیه
#include<stdio.h>
#include<conio.h>

main(){
long int a,s=0,r,i=0,j;

      printf("Enter a binery number :");
      scanf("%ld",&a);
      for(;a;i++){
      r=a%10;
      if(r) {
          for(j=i;j;j--) r*=2;
          s+=r;
        }
      a=a/10;
    }
      printf("%ld = %c",s,s);
 return 0;
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> اخبار و مباحث عمومي All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum