C/C++の宿題を片付けます 93代目at TECH
C/C++の宿題を片付けます 93代目 - 暇つぶし2ch288:デフォルトの名無しさん
07/07/18 21:39:00
>>282
#include <stdio.h>
#include <stdlib.h>
int main(void){int a,b,c;char e;if(scanf("%d %d %c",&a,&b,&e)!= 3){
fprintf(stderr, "input error\n");return EXIT_FAILURE;}switch (e) {
case '+': c = a + b; break;case '-': c = a - b; break;
case '*': c = a * b; break;case '/':
case '%':if (b == 0) {fprintf(stderr, "zero divide\n");
return EXIT_FAILURE;}if (e == '/') {c = a / b;} else {c = a % b;}
break;default:fprintf(stderr, "illegal operator\n");return EXIT_FAILURE;}
printf("result = %d", c);
return EXIT_SUCCESS;}



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch