#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
}
Private Sub Command1_Click()
x = Val(Text1.Text)
du = Fix(x)
x = (x - du) * 60
fen = Fix(x)
x = (x - fen) * 60
miao = x
Print Text1 &"=" &du &"度" &fen &"分" &miao &"秒"
End Sub
如只汪陆猜保留秒悉滚数的2位小数,可以困型把上面一行的miao换为Format(miao,"0.00")
按照题目要求编写的磅转换为千克的C语言程序如下
#include<stdio.h>
int main(){
float lb,kg
printf("请输入磅的重量数:")
scanf("%f",&lb)
kg=lb*453.6/1000
printf("%f磅等于%f千克",lb,kg)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)