2015-09-09 [Little information]--data capture and processing engineer--3 face

Source: Internet
Author: User

Time: 2015-09-09 13:40 ~ 14:40

Location: No. 1th, Wang Zhuang Road, Haidian District , Beijing Tongfang Science and Technology Plaza, Block D, West 7

1. How many bits a and B are different

`#include <climits>#include<cmath>#include<cstdlib>#include<cstring>#include<iostream>#include<iomanip>#include<string>using namespacestd;//Return the number of difference bits of a and B//Return 1 If a = 0 and B = 1//Return 2 If a = 0 and B = 3intDiffintAintb) {    intAns =0; A= a ^b; inti = +; intj =1;  while(i--) {        if(A &j) Ans++; J<<=1; }    returnans;}intMain () {Const structTestCase {intA; intb; intret; } test_cases[]= {        { 0,1,1 },        { 0,2,1 },        { 0,3,2 },        { 1,3,1 },        { -1,0, + },        { -1,3, - },        { -1,0x7FFFFFFF,1 },    };  for(intIII =0; III <sizeof(test_cases)/sizeof(TestCase); iii++) {        ConstTestCase &AMP;TC =TEST_CASES[III]; Const intActual_ret =diff (TC.A, tc.b); if(Tc.ret! =Actual_ret) {cout<<"Case #"<< III <<": FAILED"<<Endl; cout<<"\texpected ret="<< Tc.ret <<Endl; cout<<"\tacutal ret="<< Actual_ret <<Endl; }    }    return 0;}`

2. grep finds the first line

grep "What_you_want" Target_file | Head-n 1

3. Find the first log of a day in a 100GB file

The practical application of binary search requires attention to robustness.

2015-09-09 [Little information]--data capture and processing engineer--3 face

Related Keywords:

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.