라벨이 대수학(산술정수론)인 게시물 표시

C 언어: 비트 연산(bitwise operation)_000025

C언어: xor 연산(swap) /// 연산 x = x ^ y y = y ^ x x = x ^ y /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #include   < stdio.h > #include   < stdlib.h > #include   < time.h >   // core gate -------------------------------------------------------------------- extern   inline   int  not_gate( int  x)          {  return  (~x);  }        // not gate extern   inline   int  or_gate( int  x,  int  y)    {  return  (x  |  y); }      // or gate extern   inline   int  and_gate( int  x,  int  y)   {  return  (x  &  y); }      // and gate extern   inline   int  xor_gate( int  x,  int  y)   {  return  (x ^ y); }      // xor gate extern   inline   int  l_shift( int  x,  int  bits) {  return  (x  < <  bits); }  // left shift  extern   inline   int  r_shift( int  x,  int  bits) {  return  (x  > >  bits); }  // right shift //---------------------------------------------------------------------------

C 언어: 수학+_000003

C언어: 수학연산 000003 /// 연산 더하기 (0 ~ 9) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 #include   < stdio.h > #include   < stdlib.h > #include   < time.h >   #define  MAX_Q         10   // 최대 질문 개수 #define  CONVERSATION  1 #define  CLOSING       0   static   unsigned   int  rand_num1  =   0 ; static   unsigned   int  rand_num2  =   0 ; static   unsigned   int  ans        =   0 ;   static   char  input  =   'r' ;   void  func_question( void ); void  func_answer( void ); void  func_result( void );    int  main( void ) {      int  question  =   0 ;      int  status    =   0 ;      int  rt_int;          do  {          printf ( "대화(1) | 종료(1 이외의 수): " );            rt_int  =   scanf ( "%d" ,  & status);          if  (getchar()  ! =   '\n' ) {  // for scanf() statu

C 언어: 수학+_000002

C언어: 수학연산 000002 /// 연산 1 큰 수, 1 작은 수, 0 이해하기(0 ~ 9) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 #include   < stdio.h > #include   < stdlib.h > #include   < time.h >   #define  MAX_Q         10   // 최대 질문 개수 #define  CONVERSATION  1 #define  CLOSING       0   static   unsigned   int  random_num  =   0 ; static   unsigned   int  gt_or_lt    =   0 ; static   unsigned   int  ans         =   0 ;   static   char  input  =   'c' ;   void  func_question( void ); void  func_answer( void ); void  func_result( void );    int  main( void ) {      int  question  =   0 ;      int  status    =   0 ;      int  rt_int;          do  {          printf ( "대화(1) | 종료(1 이외의 

C 언어: 수학+_000001

C언어: 수학연산 000001 /// 연산 1 ~ 9까지 수 알고 쓰기 /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 #include   < stdio.h > #include   < stdlib.h > #include   < time.h >   #define  MAX_Q         10   // 최대 질문 개수 #define  CONVERSATION  1 #define  CLOSING       0    static   unsigned   int  random_num  =   0 ; static   unsigned   int  ans         =   0 ;   void  func_question( void ); void  func_answer( void ); void  func_result( void );    int  main( void ) {      int  question  =   0 ;      int  status    =   0 ;      int  rt_int;         do  {          printf ( "대화(1) | 종료(1 이외의 수): " );           rt_int  =   scanf ( "%d" ,  & status);          if  (getchar()  ! =   '\n' ) {  // for scanf() status = 1aaa, aaa ...         

C 언어: 비트 연산(bitwise operation)_000027

C언어: 몫 /// 연산 a = b * q + r, (a, b는 정수, q는 몫, r은 나머지) /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 #include   < stdio.h >   void  show_binary( int  value);  // decimal to binary   // minimize usage of (/ → * → - → +) operator and floating-point // core gate -------------------------------------------------------------------- extern   inline   int  not_gate( int  x)          {  return  (~x);  }        // not gate extern   inline   int  or_gate( int  x,  int  y)    {  return  (x  |  y); }      // or gate extern   inline   int  and_gate( int  x,  int  y)   {  return  (x  &  y); }      // and gate extern   inline   int  xor_gate( int  x,  int  y)   {  return  (x ^ y); }      // xor gate extern   inline   int  l_shift( int  x,  int  bits) {  return  (x  < <  bits