<span style="font-size:24px;">#include<stdio.h> void print_menu() { printf("*********************\n"); printf("***1.add 2.sub***\n"); printf("***3.mul 4.div***\n"); printf("*********************\n"); } int add(int x,int y) { return x+y; } int sub(int x,int y) { return x-y; } int mul(int x,int y) { return x*y; } int div(int x,int y) { return x/y; } int main() { int m,n; int input=1; while(input) { print_menu(); printf("请选择>"); scanf("%d",&input); printf("请输入俩个操作数:"); scanf("%d %d",&m,&n); switch(input) { case 1: printf("%d\n",add(m,n)); break; case 2: printf("%d\n",sub(m,n)); break; case 3: printf("%d\n",mul(m,n)); break; case 4: printf("%d\n",div(m,n)); break; default: return 0; break; } }</span>
时间: 2024-11-11 15:23:11