关闭

hello world

62人阅读 评论(0) 收藏 举报

  ----------->coding --------->c ---->cpp----------->cc----------->as------>ld ------------->elf loader------------>network

it's easy!

1、c hello world

  1 #include <stdio.h>
  2 int main()
  3 {
  4         printf("hello world\n");
  5         return 0;
  6 }


2、coding - yinyang is not the binary

 #include <iostream>
  2 #include <cstdlib>
  3 using namespace std;
  4 class yinyang{
  5         public:
  6                 yinyang(int one=1, int zero=0) {m_yin = zero, m_yang = one;}
  7                 void print_binary(int v);
  8                 inline void print_yin(void){print_binary(m_yin);}
  9                 inline void print_yang(void){print_binary(m_yang);}
 10                 void op_and(void);
 11                 void op_or(void);
 12                 void op_xor(void);
 13                 void op_not(void);
 14         private:
 15                 int m_yin, m_yang;
 16 };
 17 void yinyang::print_binary(int v)
 18 {
 19         int size = sizeof (int) * 8;
 20         while (size--){
 21                 if (v & 1<<size) cout<<"1 ";
 22                 else cout<<"0 ";
 23         }
 24         cout<<endl;
 25 }
 26
 27 void yinyang::op_and(void)
 28 {
 29         cout<<"op_and:";
 30         print_binary(m_yin & m_yang);
 31 }
          void yinyang::op_or(void)
 34 {
 35         cout<<"op_or:";
 36         print_binary(m_yin | m_yang);
 37 }
 38
 39 void yinyang::op_xor(void)
 40 {
 41         cout<<"op_xor:";
 42         print_binary(m_yin ^ m_yang);
 43 }
 44
 45 void yinyang::op_not(void){
 46         cout<<"op_not:";
 47         print_binary(~m_yin);
 48         print_binary(~m_yang);
 49 }
 50
 51 int main()
 52 {
 53         srand(time(NULL));
 54         int a = rand();
 55         int b = rand();
 56         yinyang binary(a,b);
 57         cout<<hex<<b<<":";
 58         binary.print_yin();
 59         cout<<hex<<a<<":";
 60         binary.print_yang();
 61         binary.op_and();
 62         binary.op_or();
 63         binary.op_xor();
 64         binary.op_not();
 65         return 0;
 66 }
                                      

3:math is coding .

   1 #include <stdio.h>
  2 int main()
  3 {
  4         int i = 1;
  5         while (i!=0)
  6         {
  7                 scanf("%d", &i);
  8                 if (( i & (i-1))==0) printf("is 2n\n");
  9                 else printf("is not 2n!\n");
 10         }
 11         return 0;
 12 }

4、computer is mating:

1 #include <stdio.h>
  2
  3 union fi{
  4         float f;
  5         int i;
  6         unsigned char x[4];
  7 };
  8
  9 char endian(void){
 10         int i = ~0 - 1;
 11         return *(unsigned char *)&i == 0xfe ? 'L' : 'B';
 12 }
 13
 14 int main()
 15 {
 16         union fi ufi;
 17         endian()=='L' ? (ufi.x[0] = 0xcd, ufi.x[1] = 0xcc, ufi.x[2]=0x8c, ufi.x[3] = 0x3f) :
 18         (ufi.x[0] = 0x3f, ufi.x[1] = 0x8c, ufi.x[2] = 0xcc, ufi.x[3] = 0xcd);
 19         printf("%d\t%e\n", ufi.i, ufi.f);
 20         return 0;
 21 }

5、围-结构化方法-转化思想

 无极->太极->阴阳->四象->八卦->万物->无极;

.c----->.i------>.S-------->.o------------------>elf------------>process------------>thread---------------->network

|      cpp      cc            as                        ld                 

coding

L0:机器码层

L1:汇编层

L3:源码层



0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2100次
    • 积分:90
    • 等级:
    • 排名:千里之外
    • 原创:9篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档