C++程序不显示就自动退出
编好以后,编译器没有提示出现错误,但是运行没有反应,编译器就显示程序已退出。用的是vs2005,以下是代码#include<stdio.h>#include<stdafx...
编好以后,编译器没有提示出现错误,但是运行没有反应,编译器就显示程序已退出。
用的是vs2005,以下是代码
#include <stdio.h>
#include <stdafx.h>
#include <iostream>
#include <conio.h>
using namespace std;
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
double height = 0.;
double weight = 0.;
cout<<"Enter your weight(kg):\n";
cin>>weight;
cout<<"Enter your height(m):\n";
cin>>height;
cout<<"the BMI is \n";
cout<<weight/(height*height);
if(weight/(height*height)<18.5)
cout<<"You are too thin\n";
if(weight/(height*height)>=18.5&&weight/(height*height)<=23.9)
cout<<"Your weight is healthy\n";
if(weight/(height*height)>23.9)
cout<<"You are too fat\n";
system("pause");
return 0;
} 展开
用的是vs2005,以下是代码
#include <stdio.h>
#include <stdafx.h>
#include <iostream>
#include <conio.h>
using namespace std;
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
double height = 0.;
double weight = 0.;
cout<<"Enter your weight(kg):\n";
cin>>weight;
cout<<"Enter your height(m):\n";
cin>>height;
cout<<"the BMI is \n";
cout<<weight/(height*height);
if(weight/(height*height)<18.5)
cout<<"You are too thin\n";
if(weight/(height*height)>=18.5&&weight/(height*height)<=23.9)
cout<<"Your weight is healthy\n";
if(weight/(height*height)>23.9)
cout<<"You are too fat\n";
system("pause");
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询