|
发表于 2016-9-10 12:59:14
|
显示全部楼层
- #if(1)
- /*错误: error C4996: 'scanf':
- To disable deprecation, use “_CRT_SECURE_NO_WARNINGS”
- //向右边拉把双引号的内容复制然后预处理第一行进行宏定义如下
- */
- #define _CRT_SECURE_NO_WARNINGS//这个在vs2013版本需添加
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int my_max(int x, int y);//max 和 min 因该是已经在库函数中定义过的了
- int my_min(int x, int y);//你再次定义就会重复定义;改改函数名就好
- int(*p)(int, int);
- int a, b, c, n;
- printf("please enter two integer a and b :\n");
- scanf_s("%d,%d", &a, &b);
- printf("if you want get the biger one,plaese enter 1,or small 2\n");
- scanf("%d", &n);
- if (n == 1)
- {
- p = my_max;
- c = (*p)(a, b);
- printf(" the biger one is %d\n", c);
- system("pause");
- }
- if (n == 2)
- {
- p = my_min;
- c = (*p)(a, b);
- printf(" min = %d\n", c);
- system("pause");
- }
- return 0;
- }
- int my_max(int x, int y)
- {
- int z;
- if (x>y) z = x;
- else z = y;
- return z;
- }
- int my_min(int x, int y)
- {
- int z;
- z = (x<y) ? x : y;
- return z;
- }
- #endif
复制代码 |
|