Code Hunt (1)

Source: Internet
Author: User

Code Hunt This site is similar to learn codecademyd, all through the pass, to give you some fragmented program fragments, and then you need to complete it needs to return the results. But the question of code hunt is a little more nonsensical, because he will only give you the data you need to return, and it doesn't tell you exactly how to get it. So it's more like games (some people say this is Microsoft's online game, in fact really very good, amway a bit). Of course, this site also has C # learning (seemingly online has Daniel Reading brush this into the programming of the United States C # rematch, hahaha think of those who learn C # also play games every day, thanks to me to hit) fled. Well, it would be nice to sign up for a Microsoft account or Facebook, but I just wrote the second pass. The following is my personal answer but all get Samsung, if someone has better communication ...

Website: https://www.codehunt.com

00.01 simple familiar with the operation of the site.

00.02

 Public class Program {    publicstaticint Puzzle (int  x) {          return x+1;}    }

00.03

 Public class Program {    publicstaticint Puzzle (int  x) {          return x*2;}    }

00.04

 Public class Program {    publicstaticint Puzzle (intint  y) {         return x+y;    }}

01.01

 Public class Program {    publicstaticint Puzzle (int  x) {          Return -x;    }}

01.02

 Public class Program {    publicstaticint Puzzle (int  x) {         return x-2;}    }

01.03

OK, this question 33 and 1089 of the relationship, really did not do it, had to try to more than a few times when the topic to give more data finally know.

 Public class Program {    publicstaticint Puzzle (int  x) {          return x*x;}    }

01.04

 Public class Program {    publicstaticint Puzzle (int  x) {          return x*3;}    }

01.05

 Public class Program {    publicstaticint Puzzle (int  x) {         return X/3;}    }

01.06

 Public class Program {    publicstaticint Puzzle (int  x) {          Return 4/x;    }}

01.07

 Public class Program {    publicstaticint Puzzle (intint  y) {         return xy;    }}

01.08

 Public class Program {    publicstaticint Puzzle (intint  y) {          return x+2*y;    }}

01.09

 Public class Program {    publicstaticint Puzzle (intint  y) {         return x*y;    }}

01.10

Well, this problem with 01.03 is a small boss ah. Or am I too scum ...

 Public class Program {    publicstaticint Puzzle (intint  y) {         return X+Y/3;}    }

01.11

 Public class Program {    publicstaticint Puzzle (intint  y) {          return x/y;    }}

01.12

 Public class Program {    publicstaticint Puzzle (int  x) {          return x%3;}    }

01.13

From the previous question to come out naturally ...

 Public class Program {    publicstaticint Puzzle (int  x) {          return x%3+1;}    }

01.14

 Public class Program {    publicstaticint Puzzle (int  x) {         return 10%x;}    }

01.15

 Public class Program {    publicstaticint Puzzle (intint int z) {        return (x+y+z)/3;    }}

02.01

This closes the beginning into the Java array of learning .... But I did not really learn Java, in fact, just finished the C array, so only Baidu Google use. The two definitions of int[] A and int a [] are allowed in Java, but the former is better because it tells us explicitly that an array is defined.

 Public class Program {    publicstaticint[] Puzzle (int  n) {        int  i;         int [] score=newint[n];          for (i=0;i<n;i++)        {            Score[i]=i;        }         return score;}    }

02.02

 Public class Program {    publicstaticint[] Puzzle (int  n) {        int  i;         int [] score=newint[n];          for (i=0;i<n;i++)        {            score[i]=i*n;        }         return score;}    }

02.03

 Public class Program {    publicstaticint[] Puzzle (int  n) {        int  i;         int [] a=newint[n];          for (i=0;i<n;i++)        {            a[i]=i*i;        }         return A;       }}

02.04

This is a bit of Java color, V.length is the property of the array in Java: length.

 Public class Program {    publicstaticint Puzzle (int[] v) {            int sum=0, I;              for (i=0;i<v.length;i++)            {                 sum+ =v[i]            ;            } return sum;    }}

02.05

This problem, we can go to see the surface, really is ....

 Public class Program {    publicstaticint Puzzle (int  n) {          Return N (n-1) * (2*n-1)/6;    } }

02.06

Enter the string. There are many methods for string literals in Java, such as the method of finding the length of the string s: S.length (). Note the difference: s.length () is different from the above. Length, one is the method one is the attribute, as for the difference and meaning of the two later. In fact, the length method is the same as the strlen, which does not calculate the NUL, which is ' the '.

 Public class Program {    publicstaticint  Puzzle (String s) {          = S.replace ("A", " ");                     return s.length ()-s1.length ();}    }

02.07

I learned the simplest way to convert a character variable into a string, but there are also special methods in Java. The meaning of "+x and x+" is to convert X to the string "x".

 Public class Program {    publicstaticintchar  x) {        String s1= S.replace ("+x," ");         return s.length ()-s1.length ();}    }

The previous write here, Java to now is also just getting started, also looking at "Java Core technology" and some video, but still did not fully understand OOP, so to try. And look online said. Replace this method has the content of the regular expression, but also need to study a bit ...

Code Hunt (1)

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.