编写一个方法将两个短的int变量组合成一个Integer类型变量和两个 方法从组合变量中检索short int 在下面的示例中:x应该是整数的一半,y应该在下半部分。 外汇。
短 int x = 10 ; shortint y = 11 ; int combineVar = combineXY(x,y); short int a = getX(combineVar) short int b = getY(combineVar) intcombineXY(shortint x _, short inty_) { // 返回COMBINED INT; } 短 int getX( int var_) {} short int getY( int var_) {}我尝试了什么: 不知道如何从combinevar
解决方案Quote:
不知道如何从combinevar中检索getX和getY 检索getx和gety的方法取决于你将它们组合起来的方式。 多少小时和分钟是90分钟? 我们不做你的HomeWork。 HomeWork不会测试你的技能,乞求别人做你的工作,它设置为让您思考并帮助您的老师检查您对所学课程的理解以及您应用这些课程时遇到的问题。 你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。 你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。 所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。 [更新] 您的问题与以下相同: - 将x小时和分钟组合成几分钟。 - 从多个合计分钟数,得到小时数和分钟数。 你的作业使用相同的逻辑。
你必须了解短整数和整数可以容纳的最大数字。另请查看这些var的位大小。 在C ++中常数显示可以表示的最大数字。这取决于位大小。 所以学习一点 C ++ 。并且一定要理解第3.8章的作业。
Write a method to combine two short int variables into one Integer type variable and two method to retrieve the short int from the combined variable In below example: x should be in higher half of integer and y should be in lower half. Forex.
Short int x = 10; shortint y = 11; int combineVar = combineXY (x, y); short int a = getX(combineVar) short int b = getY(combineVar) intcombineXY(shortint x_,short inty_) { //Return COMBINED INT; } short int getX(int var_) { } short int getY(int var_) { }What I have tried: Don't know how to retrieve getX and getY from combinevar
解决方案 Quote:Don't know how to retrieve getX and getY from combinevar
The way to retrieve getx and gety depend on the way you combine them. How many hours and minutes is 90 minutes ? We do not do your HomeWork. HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will help your teacher spot your weaknesses and set remedial actions. Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning. So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help. [Update] Your problem is same as: - combine x hours and y minutes into a number of minutes. - from a number of combined minutes, get the number of hours and of minutes. your homework is using the same logic.
You must understand what the biggest number is which an short integer and an integer can hold. Take also a look at the bit size of these var. In C++ are constants which shows the biggest number which can be represented. It is depending on the bit size. So learn a bit of C++ . And be sure to understand chapter 3.8 for your homework.更多推荐
如何从以下程序中找到getx和gety
发布评论