#include<iostream.h>
int main()
{
double num
double n
double m
while(true)
{
cout<<"请选择要输入的单位:1、毫米;2、厘米;3、米;4、千米" <<endl
cin >> num
cout << "请输入单位长度" <<endl
cin >> m
if(num == 1)
{
cout << "请选择要转换的单位:1、厘米;2、米;3、千兆悄米" <<endl
cin >> n
if(n == 1)
{
cout<<"毫米转换成厘米结果为:"<<m<<"mm="<<m/100<<"cm"<<endl
} else if(n == 2) {
cout<<"毫米转换成米结果为:"<<m<<"mm="<<m/1000<<"m"<<endl
} else if(n == 3) {
cout<<"毫米转换成千米结果为:"<<m<<"mm="<<m/1000000<<"km"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else if(num == 2) {
cout << "请选择要转换的单位:1、毫米;2、米;3、千米" <<endl
cin >> n
if(n == 1)
{
cout<<"厘米转换成毫米结果为:"<<m<<"cm="<<m*100<<"mm"<<endl
} else if(n == 2) {
cout<<"厘米转换成米结果为:"<<m<<"cm="<<m/10<<"m"<<endl
} else if(n == 3) {
cout<<"厘米转换成千米结果为:"<<m<<"cm="<<m/10000<<"km"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else if(num == 3) {
cout << "请选择要转换的单位:1、毫米;2、厘米;3、千米" <<endl
cin >> n
if(n == 1)
{
cout<<"改慧米转换成毫米结果为:"<<m<<"m="<<m*1000<<"mm"<<endl
} else if(n == 2) {
cout<<"米转换成厘米结果族歼渣为:"<<m<<"m="<<m*10<<"cm"<<endl
} else if(n == 3) {
cout<<"米转换成千米结果为:"<<m<<"m="<<m/1000<<"km"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else if(num == 4) {
cout << "请选择要转换的单位:1、毫米;2、厘米;3、米" <<endl
cin >> n
if(n == 1)
{
cout<<"千米转换成毫米结果为:"<<m<<"km="<<m*1000*1000<<"mm"<<endl
} else if(n == 2) {
cout<<"千米转换成厘米结果为:"<<m<<"km="<<m*10*1000<<"cm"<<endl
} else if(n == 3) {
cout<<"千米转换成米结果为:"<<m<<"km="<<m*1000<<"m"<<endl
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
} else {
cout << "输入有误,请重新输入" <<endl
continue
}
}
return 0
}
这是卖颂用系卜答统函数的pow()
#include <stdio.h>
#include <math.h>
int main(void)
{
double i = 0, sum = 0
for(i = 0i <型配慧 64i++)
sum += pow(2.0, i)
printf("总共的米数为 %lf\n第64格的米数为 %lf\n", sum, pow(2.0, 63.0))
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)