如何从以下程序中找到getx和gety [英] How do I find getx and gety from the following program

查看:91
本文介绍了如何从以下程序中找到getx和gety的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写一个方法将两个短的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆