#include<stdio.h>
void add(int x, int y)
{
int z;
z = x + y;
printf ("total = %d" , z );
}
void multiply(int g, int h)
{
int i;
i = g * h;
printf ("multiply=%d" , i );
}
main()
{
char choice;
int i , j;
printf ("Enter two integer:\n");
scanf ("%d,%d",&i,&j);
printf ("a for add \n");
printf ("m for multiply \n");
printf ("\nPlease input your choice:");
getchar();
scanf ("%c" , & choice);
switch (choice)
{
case 'a':
add(i , j);
break;
case 'm':
multiply(i , j);
break;
default: printf ("Invalid choice, please try again.\n\n");
}
}
我英语不太好,但是看了个大概不知道你是不是这个意思先输入两个数字然后选择功能调用函数
void add(int x, int y)
{
int z;
z = x + y;
printf ("total = %d" , z );
}
void multiply(int g, int h)
{
int i;
i = g * h;
printf ("multiply=%d" , i );
}
main()
{
char choice;
int i , j;
printf ("Enter two integer:\n");
scanf ("%d,%d",&i,&j);
printf ("a for add \n");
printf ("m for multiply \n");
printf ("\nPlease input your choice:");
getchar();
scanf ("%c" , & choice);
switch (choice)
{
case 'a':
add(i , j);
break;
case 'm':
multiply(i , j);
break;
default: printf ("Invalid choice, please try again.\n\n");
}
}
我英语不太好,但是看了个大概不知道你是不是这个意思先输入两个数字然后选择功能调用函数