Родитель
							
								
									7d171d71f6
								
							
						
					
					
						Сommit
						193cab7c1f
					
				@ -0,0 +1,69 @@
 | 
				
			|||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#include <locale.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint16_t reverse(uint16_t x)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    x = (x & 0xFF) << 8 | (x & 0xFF00) >> 8;
 | 
				
			||||||
 | 
					    return x;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void print_in_hex(uint16_t num) 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    printf("%04X ", num);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void print_in_binary(uint16_t num) 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    for (int i = 15; i >= 0; i--) 
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        printf("%d", (num >> i) & 1);
 | 
				
			||||||
 | 
					        if (i % 8 == 0) 
 | 
				
			||||||
 | 
					            printf(" ");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main() 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    setlocale(LC_ALL, "Russian");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint16_t operand1, operand2;
 | 
				
			||||||
 | 
					    char symbol;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    scanf("%hu %c %hu", &operand1, &symbol, &operand2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operand1 = reverse(operand1);
 | 
				
			||||||
 | 
					    operand2 = reverse(operand2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint16_t result;
 | 
				
			||||||
 | 
					    switch (symbol) 
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    case '&':
 | 
				
			||||||
 | 
					        result = operand1 & operand2;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case '|':
 | 
				
			||||||
 | 
					        result = operand1 | operand2;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    case '^':
 | 
				
			||||||
 | 
					        result = operand1 ^ operand2;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    default:
 | 
				
			||||||
 | 
					        printf("Íåâåðíûé îïåðàòîð\n");
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    printf("\nÐåçóëüòàò: ");
 | 
				
			||||||
 | 
					    print_in_hex(operand1);
 | 
				
			||||||
 | 
					    printf("%c ", symbol);
 | 
				
			||||||
 | 
					    print_in_hex(operand2);
 | 
				
			||||||
 | 
					    printf("= ");
 | 
				
			||||||
 | 
					    print_in_binary(operand1);
 | 
				
			||||||
 | 
					    printf("%c ", symbol);
 | 
				
			||||||
 | 
					    print_in_binary(operand2);
 | 
				
			||||||
 | 
					    printf("= ");
 | 
				
			||||||
 | 
					    print_in_binary(result);
 | 
				
			||||||
 | 
					    printf("\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    system("pause");
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
					Загрузка…
					
					
				
		Ссылка в новой задаче