#include<iostream>
int main(void)
{
using namespace std;
char a = 65;
char b = 'A';//在ASCALL的平台下这两条语句等价;
cout << a << endl;
cout << b << endl;
return 0;
}
#include<iostream>
const int FOOT_TO_TNCH = 12;
int main(void)
{
using namespace std;
int height;
cout << "Please enter your height in inches_";
cin >> height;
cout << "Your height convert to " << height / FOOT_TO_TNCH
<< " foot and " << height % FOOT_TO_TNCH << " inches" << endl;
return 0;
}
#include<iostream>
const int FOOT_TO_INCH = 12;
const double INCH_TO_METER = 0.0254;
const double KILLOGRAM_TO_POUND = 2.2;
int main(void)
{
using namespace std;
int height_foot, height_inch;
double weight_pound,height,weight,bmi;
cout << "Please enter your height foot:";
cin >> height_foot;
cout << "Please enter your height inch:";
cin >> height_inch;
cout << "Please enter your weight in pounds:";
cin >> weight_pound;
height = (height_foot*FOOT_TO_INCH+height_inch)*INCH_TO_METER;
weight = weight_pound / KILLOGRAM_TO_POUND;
bmi = weight / (height*height);
cout << "Your bmi is " << bmi << endl;
return 0;
}
#include<iostream>
const int DEGREE_TO_MINUTE = 60;
const int DEGREE_TO_SECOND = 3600;
int main(void)
{
using namespace std;
int degree, minute,second;
double degree_style;
cout << "Enter a latitude in degrees,minutes,and seconds:" << endl;
cout << "First,enter your degree:";
cin >> degree;
cout << "Next,enter the minutes of arc:";
cin >> minute;
cout << "Finally,enter the seconds of arc:";
cin >> second;
degree_style = degree + (double)minute / DEGREE_TO_MINUTE + (double)second / DEGREE_TO_SECOND;
cout << degree << " degrees," << minute << " minutes," << second << " seconds = " << degree_style << " degrees" << endl;
return 0;
}
#include<iostream>
const int DAY_HOUR = 24;
const int HOUR_TO_MINUTE = 60;
const int MINUTE_TO_SECOND = 60;
int main(void)
{
using namespace std;
long long seconds;
int days, hours, minutes;
cout << "Please enter the number of seconds:";
cin >> seconds;
days = seconds / (DAY_HOUR * HOUR_TO_MINUTE * MINUTE_TO_SECOND);
seconds = seconds % (DAY_HOUR * HOUR_TO_MINUTE * MINUTE_TO_SECOND);
hours = seconds / (HOUR_TO_MINUTE * MINUTE_TO_SECOND);
seconds= seconds % (HOUR_TO_MINUTE * MINUTE_TO_SECOND);
minutes = seconds / MINUTE_TO_SECOND;
seconds = seconds % MINUTE_TO_SECOND;
cout << days << " days " << hours << " hours "
<< minutes << " minutes " << seconds << " seconds " << endl;
return 0;
}
#include<iostream>
int main(void)
{
using namespace std;
long long global_amount, american_amount;
double population_percent;
cout << "Enter the world's population:";
cin >> global_amount;
cout << "Enter the population of US:";
cin >> american_amount;
population_percent = 100.0 * american_amount / global_amount;
cout << "The population of the US is " << population_percent << "% of the world." << endl;
return 0;
}
#include<iostream>
int main(void)
{
using namespace std;
double distance_in_mile, fule_in_gallon;
double distance_in_kilometer, fuel_in_litre;
double fuel_consume;
cout << "Enter the distance in miles:";
cin >> distance_in_mile;
cout << "Enter the fule consume in gallon:";
cin >> fule_in_gallon;
fuel_consume = distance_in_mile / fuel_consume;
cout << "The fuel consume is " << fuel_consume << " miles/gallon." << endl;
cout << "Enter the distance in kilometer:";
cin >> distance_in_kilometer;
cout << "Enter the fuel consume in litre:";
cin >> fuel_in_litre;
fuel_consume = fuel_in_litre / distance_in_kilometer * 100;
cout << "The fuel consume is" << fuel_consume << " L/100km." << endl;
return 0;
}
#include<iostream>
const double GALLON_TO_LITRE = 3.875;
const double HKM_TO_MILE = 62.14;
int main(void)
{
using namespace std;
double fuel_consume_eur,fuel_consume_us;
cout << "Enter the fuel consume in europe(L/100Km):";
cin >> fuel_consume_eur;
fuel_consume_us = (GALLON_TO_LITRE * HKM_TO_MILE) / fuel_consume_eur;
cout << "The fuel consume is " << fuel_consume_us << " mial/gallon." << endl;
return 0;
}