用c编写一个简单的计算器

#include<stdio.h>
int main()
{
	int value1,value2;
	char op;
	scanf("%d%c%d",&value1,&op,&value2);
	switch(op){
	case'+':
		printf(" =%d\n",value1+value2);
		break;
		case'-':
		printf(" =%d\n",value1-value2);
		break;
		case'*':
		printf(" =%d\n",value1*value2);
		break;
		case'/':
			if(value2!=0){
			printf(" =%d\n",value1/value2);
			}else{
				printf("Divisor can not be 0!\n");
			}
  			break;
  		case'%':
			if(value2!=0){
			printf(" =%d\n",value1%value2);
			}else{
				printf("Divisor can not be 0!\n");
			}
			break;
  			default:
  				printf("Unknown operator\n");
  				break;
	}
			return 0;
 } 

上一篇:mysql数据查询


下一篇:用 Python 定义 Schema 并生成 Parquet 文件