#include<stdio.h> int main(void) {char ch1,ch2; i
#include<stdio.h>intmain(void){charch1,ch2;intn1,n2;ch1=getchar();ch2=getchar();n1=ch...
#include<stdio.h>
int main(void)
{char ch1,ch2; int n1,n2;
ch1=getchar(); ch2=getchar();
n1=ch1-‘0’;n2=n1*10+(ch2-‘0’);
printf("%d\n",n2);
}
这个程序为什么输入12<回车>,输出的也是12?0的ASC||码不是48吗?
求解答 如果我输入字符呢? 展开
int main(void)
{char ch1,ch2; int n1,n2;
ch1=getchar(); ch2=getchar();
n1=ch1-‘0’;n2=n1*10+(ch2-‘0’);
printf("%d\n",n2);
}
这个程序为什么输入12<回车>,输出的也是12?0的ASC||码不是48吗?
求解答 如果我输入字符呢? 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
2个回答
展开全部
输入12
ch1得到1
ch2得到2
n1=ch1-'0'=1
同理,n2=10*1+2=12
ch1得到1
ch2得到2
n1=ch1-'0'=1
同理,n2=10*1+2=12
追答
0的ASCII是48,那么1的就是49,2就是50.....
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我的报错和你的不一样。
我改了几个地方:
float->double
scanf里面的%f->%lf
你的weight后面的都写成了wight
#include<stdio.h>int main(void){ double weight; double value; printf("Are you worth your wight in rhodium?\n"); printf("Let's check it out.\n"); printf("Please enter your wight in pounds: "); scanf("%lf",&weight); value = 770 * weight * 14.5833; printf("Your wight in rhodium is worth $%.2f.\n",value); printf("You are easily worth that! If rhodium prices drop.\n"); printf("Eat more to maintain your value.\n"); return 0;}
我改了几个地方:
float->double
scanf里面的%f->%lf
你的weight后面的都写成了wight
#include<stdio.h>int main(void){ double weight; double value; printf("Are you worth your wight in rhodium?\n"); printf("Let's check it out.\n"); printf("Please enter your wight in pounds: "); scanf("%lf",&weight); value = 770 * weight * 14.5833; printf("Your wight in rhodium is worth $%.2f.\n",value); printf("You are easily worth that! If rhodium prices drop.\n"); printf("Eat more to maintain your value.\n"); return 0;}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询