#include
getchar();
fflush(stdin);
或
#include
system("pause");
或
#include
getch();
或者
#include
MessageBox(NULL,"程序结束","消息",MB_OK);
加在main()函数的
return 0;前面
完整程序:
#include
#include
int max(int, int); // 函数声明
int main(){
int a, b; // 声明两个整型变量
printf("Input two integers: "); // 以空格为分隔
scanf("%d %d", &a, &b); // 将输入的两个整数分别赋值给a, b
// 以整数形式输出最大值, a, b为实际参数(实参)
printf("The max integer is %d.\n", max(a, b));
getch();
return 0;
}
// 函数定义
int max(int num1, int num2){ // num1, num2为形式参数(形参)
if(num1>num2){ // 如果num1大于num2
return num1; // 返回num1并结束max函数
}else{ // 如果num2大于num1
return num2; // 返回num2并结束max函数
}
}
getch();
你打分号没?
PS: 也可以用system("pause");
getch()后面的分号呢?
应该是 getch();
我测试了程序没问题,是不是你软件有问题
加
getchar()