Youdao puzzle (if Daniel passes by, give me some advice)

Source: Internet
Author: User

 

Wondering ~~ If Daniel passes by, give me some advice.

I don't know why the compilation is wrong.

No error is reported if I have compiled vc6.0 and Dev g ++ respectively.

Compile Error

A: There are "Tao" Problems
Description
'Tao' is an important category of ancient Chinese philosophy. It is used to describe the origin, ontology, law, or principle of the world. Different philosophical systems have different meanings. Lao Tzu's Sutra is a classic book about 'Tao.

The original meaning of the TAO refers to the road, the smooth path, and the gradual development of the truth in the future, to express the regularity of things. This change has gone through a long history. "Yi Jing" contains "re-Self-tao, what is his blame" ("small animals"), "fulfillment" ("performance"), "repetition, the 7-day "(" Fu ") is the meaning of the Road.

Shang Shu Hong Fan said: "No good, follow the path of the king; no evil, follow the path of the king. "No party, no party", "No party", "No party", and "no party ". Here, we already have the correct meaning of government decrees, norms, and laws, indicating that the concept of "Tao" has evolved towards abstraction.

---- Excerpt from (http://dict.youdao.com)

Base64 is one of the most common encoding methods used to transmit 8-bit code on the network. It converts every three 8-bit bytes to four 6-bit bytes (3*8 = 4*6 = 24), and then adds 6-bit bytes to two more 0-bit bytes to form four 8-bit bytes, that is to say, the converted string is theoretically 1/3 longer than the original one.

Youdao engineers changed base64 encoding to base4 encoding in their spare time, namely converting each 8-bit byte into four 2-bit bytes and replacing them with four characters. The encoding and character schemes are as follows:
00 ----
01 ---- O
10 ---- d
11 ---- Space
In this way, the encoded string only contains the characters 'D', 'A', 'O', and space.

For example, the ASCII code of the character y is 121, and the corresponding binary string is 01111001. After dividing it into four parts: 01 11 10 01, the string encoded with base4 is "O do ".

The engineer in youdao is very curious about how many complete Dao strings are contained in the encoded strings according to this encoding method? A complete Dao consists of three consecutive 'D', 'A', and 'O' characters.

Input
The first line has a positive integer N, which represents the next n original strings to be encoded. (1 <= n <= 10)
Next there are n rows. Each line has an original string of no more than 106 characters. The characters in the original string may be any visible characters except line breaks in ASCII code.
Output
There are n rows in total, each of which is an integer k, which indicates the number of complete Dao contained in the original string of the input data after base4 encoding.
Sample Input
2
Www.youdao.com
Dict.youdao.com
Sample output
1
1

 

My code:

# Include <iostream> <br/> # include <string> <br/> using namespace STD; <br/> void tenconvtoother (INT ten, char s []) <br/>{< br/> int I, j; <br/> char TMP; <br/> I = 0; <br/> while (ten> 0) <br/>{< br/> If (ten % 2 <10) <br/> S [I] = '0' + ten % 2; <br/> else <br/> S [I] = 'A' + (ten % 2-10); <br/> I ++; <br/> ten/= 2; <br/>}< br/> S [I] = 0x00; <br/> for (j = 0; j <I/2; j ++) <br/> {<br/> TMP = s [J]; <br/> S [J] = s [i-j-1]; <br/> S [i-j-1] = TMP; <br/>}< br/> int main () <br/>{< br/> int T, I, A, n, l, num; <br/> char STR [1000001]; <br/> char s [70]; <br/> CIN> T; <br/> cin. ignore (); <br/> while (t --) <br/>{< br/> num = 0; <br/> memset (STR, '/0 ', sizeof (STR); <br/> memset (S, '/0', sizeof (s); <br/> string SS; <br/> cin. getline (STR, 109); <br/> N = strlen (STR); <br/> for (I = 0; I <n; I ++) <br/>{< br/> A = STR [I]; <br/> tenconvtoother (A, S); <br/> L = strlen (s ); <br/> while (L <8) <br/> {<br/> SS + = '0'; <br/> L ++; <br/>}< br/> SS = SS + S; <br/> memset (S, '/0', sizeof (s )); <br/>}< br/> L = ss. length (); <br/> for (I = 0; I <L-5; I ++) <br/> {<br/> If (ss. substr (I, 6 ). compare ("100001") = 0) <br/>{< br/> num ++; <br/>}< br/> cout <num <Endl; <br/>}< br/> return 0; <br/>}# include <iostream> <br/> # include <string> <br/> using namespace STD; <br/> void tenconvtoother (INT ten, char s []) <br/>{< br/> int I, j; <br/> char TMP; <br/> I = 0; <br/> while (ten> 0) <br/>{< br/> If (ten % 2 <10) <br/> S [I] = '0' + ten % 2; <br/> else <br/> S [I] = 'A' + (ten % 2-10); <br/> I ++; <br/> ten/= 2; <br/>}< br/> S [I] = 0x00; <br/> for (j = 0; j <I/2; j ++) <br/> {<br/> TMP = s [J]; <br/> S [J] = s [i-j-1]; <br/> S [i-j-1] = TMP; <br/>}< br/> int main () <br/>{< br/> int T, I, A, n, l, num; <br/> char STR [1000001]; <br/> char s [70]; <br/> CIN> T; <br/> cin. ignore (); <br/> while (t --) <br/>{< br/> num = 0; <br/> memset (STR, '/0 ', sizeof (STR); <br/> memset (S, '/0', sizeof (s); <br/> string SS; <br/> cin. getline (STR, 109); <br/> N = strlen (STR); <br/> for (I = 0; I <n; I ++) <br/>{< br/> A = STR [I]; <br/> tenconvtoother (A, S); <br/> L = strlen (s ); <br/> while (L <8) <br/> {<br/> SS + = '0'; <br/> L ++; <br/>}< br/> SS = SS + S; <br/> memset (S, '/0', sizeof (s); <br/>}

 

Status: Compile error view code

Compilation error message
418222.18768/Main.cc: In function ‘int main()’:418222.18768/Main.cc:39: error: ‘memset’ was not declared in this scope418222.18768/Main.cc:43: error: ‘strlen’ was not declared in this scope

 

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.