140729summer training .txt

Source: Internet
Author: User
1. The known data given by the question is a start time and an end time question.
The first response is to sort the start time.
But it is more troublesome.
I should change the angle and thinking of questions.
Sorting these questions by end time is much simpler.
2. struct
Struct move // struct is a struct Function
{
Int A; // struct Member
Double B;
Char C;
} Num [100]; // a struct array can contain multiple struct members, and the types of struct members can be different.
Int main ()
{
For (I = 0; I <n; I ++)
Scanf ("% d % lf % C", & num [I]. A, & num [I]. B, & num [I]. C );
.......
}
3. Structure-level quick sorting
# Include <stdlib. h> // header files are required for qsort sorting.
Int CMP (const void * a, const void * B)
{
Return (* (move *) a). A-(* (move *) B).;
// Move --- struct function name
//. A --- struct member name
// Because a sorts member A and A is of the int type, the int fast sorting type is used.
// Determine the format after return based on the type of the sorted members
}
Int main ()
{
...
Qsort (Num, N, sizeof (Num [0]), CMP );
}
4./* the description of the Computer expression of the inner code of the Chinese character machine is that two bytes are used, and the maximum bit of each byte is 1.
In the computer, the first part of the complement code is the sign bit. 1 indicates a negative number,
Therefore, each byte of the internal code of the Chinese character machine represents a negative decimal number.
Therefore, the statistical input string contains several Chinese characters,
You only need to find the number of characters in the string smaller than 0, and divide it by 2 to get the answer */
# Include <stdio. h>
# Include <string. h>
Char s [1005000];
Int Hanzi (char)
{
If (~ (A> 8) = 0)
//~ Bitwise inversion means to change the value 0 on each bit to 1, 1, and 0;
//> Right shift operator. The right integer expression specifies the number of digits to move.
Return 1;
Else
Return 0;
}
Int main ()
{
Int N;
Int I, Len, num;
Scanf ("% d", & N );
Getchar ();
While (n --)
{
Gets (s );
Len = strlen (s );
Num = 0;
For (I = 0; I <Len; I ++)
If (Hanzi (s [I])
Num ++;
Printf ("% d \ n", num/2 );
}
Return 0;
}
5./* Train of Thought: N ^ N:
Represented by scientific notation n ^ n = A * 10 ^ x
LG (N ^ n) = lg (A * 10 ^ X)
Reduced N * lg (n) = lg (A) + x
Shifted lg (A) = N * lg (N)-x
A = 10 ^ [N * lg (N)-x]
Because X is the number of digits n ^ n
In fact, X is the down integer of Lg (N ^ N), represented as [lg (N ^ n)]
A = 10 ^ {n * lg (N)-[lg (N ^ n)]}
(INT) A is the request
Clever and rational use of mathematical knowledge is king
Powerful log computing skills
*/
# Include <stdio. h>
# Include <math. h>
Int main ()
{
Int N;
Double I;
_ Int64 S, M;
Scanf ("% d", & N );
While (n --)
{
Scanf ("% i64d", & M );
I = m * log10 (M * 1.0 );
I-= (_ int64) I;
S = (_ int64) Pow (10, I );
// Multiply the power of POW (x, y) indicates the Y Power of X
Printf ("% i64d \ n", S );
}
Return 0;
}

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.