我照着答案打的,哪错了
程序代码:
int max(int x, int y) { return(x > y ? x : y); } int min(int x, int y) { return(x > y ? y : x); } #include<stdio.h> int main() { int max(int x, int y); int min(int x, int y); int(*p)(int x, int y); int a = 1, b = 2, n, c; int flag = 0; while (flag == 0) { printf("choose 1 or 2 in your select:\n"); scanf_s("%d", &n); if (n == 1 || n == 2) flag = 1; else { printf("There is an error in your enter,please try again!\n"); flag = 0; } } if (n == 1) p = max; else if (n == 2) p = min; c = (*p)(a, b); printf("a=%d,b=%d\n", a, b); if (n == 1) printf("max=%d\n", c); else if (n == 2) printf("min=%d\n", c); return 0; }
[此贴子已经被作者于2017-1-14 09:39编辑过]