char op; int x, y, result=0; printf("수식을 입력하시오"); printf("(예: 2 + 5) \n"); printf(">>"); scanf_s("%d %c %d", &x, &op, &y); if (op == '+') result = x + y; else if (op == '-') result = x - y; else if (op == '*') result = x * y; else if (op == '/') result = x / y; else if (op == '%') result = x % y; else printf("지원되지 않는 연산자입니다. "); printf("%d %c %d = %d ", x, op, y, result);
3 + 6 해보세요
너가 코딩한 대로 3 + 6처럼 띄어쓰기로 구분해서 입력해야함
말씀하신대로 했는데도 동작을 안하네요 ㅠㅠ 사진 수정했어요
%c 말고 %s로 해봐
안대요 ㅠㅠㅠㅠ
아 기억이 가물가물한데 %c로 다시 바꾸고 &op 에서 & 떼고 그냥 op 써봐
이러면 빌드가 안돼요 ㅠㅠ
헛짓하게 해서 미안 이거 봐봐
https://choryeonworkshop.tistory.com/m/119
char op; int x, y, result=0; printf("수식을 입력하시오"); printf("(예: 2 + 5) \n"); printf(">>"); scanf_s("%d %c %d", &x, &op, &y); if (op == '+') result = x + y; else if (op == '-') result = x - y; else if (op == '*') result = x * y; else if (op == '/') result = x / y; else if (op == '%') result = x % y; else printf("지원되지 않는 연산자입니다. "); printf("%d %c %d = %d ", x, op, y, result);