English 中文(简体)
我不理解我为什么在我管理这一法典时会“失败”。 这是目标C Im, 包括所涉方法的m。
原标题:I don t understand Why I m getting "inf" when I run this code. This is objective C I m including .m file of the method in question
-(void) reduce
{
 int u = numerator;
 int v = denominator;
 int temp;

 while (temp !=0) {

  temp = u % v;
  u = v;
  v = temp;
 }

 numerator /=u;
 denominator /=v;
}
最佳回答

你的分裂是零。 我认为,最后一点应该是:

denominator /= u;
问题回答

另外,你也表现出了初步的诱惑。

我认为,你在那里重新开车,取得非零价值。 这让你进入了坡道,它正常运行和计算,直到温室零。 因为,如果休息时间为零,那么休息时间在休息时间的底部就算出车价值,那么就等于休息时间。 因此,当你通过 v分裂时。

在你开始路口之前,先采用“温” = 1,以避免在路上出现“海因”。 由于变数在分配时含有垃圾,因此很有可能是非零,但不是无限期的,因此,每当一次,你都会得到一个不警告的错误答案。 这将是一场皇家疼痛。

最后,你们的变量选择不同的名称! 图瓦卢是这样。 如果你打电话,就瞄准了Denominator和目标Numerator,你很可能不会写过字。

numerator /= targetNumerator;
denominator /= targetDenominator;

......或至少可以更清楚地看到你犯了错误。





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签