Lan Yi Education 14th Day record

Source: Internet
Author: User

Today is September 6. Came to the 14th day of Lan Yi. Miss Liu did not speak a new lesson today, but led us to do a premium version of the calculator. I also made a simple calculator for the last two days in the two edition. But today, after listening to the teacher's explanation, found that their own code has a lot of too cumbersome place. Lots of things to know about improvement. There is also the discovery of the first two days of the code has been somewhat forgotten. For example, how to replace the data in the array and how to stitch the string changes. And the biggest harvest today is how to achieve the priority calculation.

for (int i=0; i<self.) operators. Count; i++) {

nsstring *operator = self. operators [i];

if ([operator isequaltostring:@ "x"]| | [Operator isequaltostring:@ "÷"]) {

float number1 = [self. Numbers[i] floatvalue];

float number2 = [self. Numbers[i+1] floatvalue];

float result = 0;

if ([operator isequaltostring:@ "x"]) {

result = Number1 * NUMBER2;

}Else{

result = Number1/number2;

}

// Remove The number of two operations and insert the results back into the

[Self. numbers removeobjectatindex: i];

[Self. numbers removeobjectatindex: i];

[Self. numbers insertobject:@ (result) atindex: i];

// Delete the current operator

[Self. operators removeobjectatindex: i];

// to ensure that every symbol in the array is traversed

i--;

}

}

There is today in the work of the teacher left to find that there are many details of the poor handling, to find a bug wasted a long time. Will certainly be improved in the future.



Lan Yi Education 14th Day record

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.