I used to take a written test. One of the questions in the test was to calculate the number of times that 1 appeared within 40 billion. At that time, I only gave the idea. The specific implementation was not written. Now I will list the specific implementation code. The following code can only calculate the number less than the N power of 10, instead of the x * 10 ^ N power. To expand the calculation, we also need to... SyntaxHighlighter. all ();
I us
int rand7() { return rand()%7+1; } int rand10(){ int x=0; do { x=(rand7()-1)*7+rand7(); } while(x>40); return x%10+1;}
Analysis: To ensure the even distribution of rand10 () on integers 1-10, you can construct a random integer interval with a 1
From: http://blog.csdn.net/furturerock/article/details/6850634View Code
1 int rand7() 2 { 3 return rand()%7+1; 4 } 5 6 int rand10() 7 { 8 int x=0; 9 do10 {11 x=(rand7()-1)*7+rand7();12 }13 while(x>40);14 return x%10+1;15 }
Analysis: To ensure the even distribution of rand10 () on integers
In the shell, see ">1" and ">2" always do not understand what meaning. After the search on the internet to dispel doubts. Actually, this is two kinds of output.
In a shell program, the most commonly used FD (file descriptor) is about three, respectively:
0 is a file descriptor that represents the standard input (stdin)1 is a file descriptor representing the standard output (stdout)
2 is a file descriptor
I used to take a written test. One of the questions in the test was to calculate the number of times that 1 appeared within 40 billion. At that time, I only gave the idea. The specific implementation was not written. Now I will list the specific implementation code.
The following code can only calculate the number less than the N power of 10, rather than the x 10 ^ N power. To expand the computation, you must complete the code.
* Calculate the number
Title: Given a positive integer in decimal, write down all integers starting with 1, to N, and then count the number of "1" that appears.Requirement: Write a function f (n) to return the number of "1" occurrences between 1 and N. For example F (12) = 5. Within a 32-bit integer range, the maximum n of the "F (n) =n" t
A friend recently discussed with me whether statements in the Where 1 = 1 and format will affect the performance. The final conclusion is no effect.Although the conclusion is correct, the understanding of the problem is far from the root of the problem. In fact, in the process of writing T-SQL statements often make a mistake is to draw a very narrow conclusion, and then teach the Bible, for the T-SQL field,
Recently in the "Jian Point offer", face question 32 of the topic: Enter an integer n, the number from 1 to n decimal representation of the n integer 1 occurrences. For example, input 12, from 1 to 12 of these integers contain 1 of the numbers are 1, 10, 11, and 12, 11 have
Rank $1 $ Matrix
$ \ BF proposition: $ set the real matrix $ A ={\ left ({A_1}, \ cdots, {a_n }}\ right) ^ t} \ left ({A_1}, \ cdots, {a_n }}\ right) $, and $ \ sum \ limits _ {k = 1} ^ n {A_k} ^ 2} = 1 $, proof: $ \ left | {e-2a} \ right | =-1 $
$ \ BF exercise: $ \ BF (09 Nankai Wu) $ set $ V $ to a number field $ p
Transferred from: http://blog.csdn.net/phpwish/article/details/7845921Look at the database structure design of the project today and find a strange place.' Xxx_detail ' delflag ' int (1) not NULL DEFAULT ' 0 ' COMMENT ' Remove flag ',' Xxx_category ' delflag ' tinyint (1) Not NULL DEFAULT ' 0 ' COMMENT ' delete tag ',Question: What is the difference between int (1
Python homework Lesson 1 and python Lesson 1
I started learning from scratch. Recently, all the students around me are learning. I also want to try it. Hey, I'll write it down. I can come and see it next time I don't remember it ~~
Python homework Lesson 11) login. Three inputs are locked. login is not allowed next time2) Design a three-level menu. The menu content can be customized. If q is input at any le
The role of SQL where 1=1 and 0=1where 1=1; This condition is always true, and in the case of an indefinite number of query conditions, the 1=1 can be a convenient specification statement. A, do not use where
You have not met in SQL 1 is not equal to 1 (1Let's start with a brief introduction to the four numeric data types in the header.In T-SQL, numeric and decimal are exact numeric data types, while float and real are approximate numeric data types.Numeric and decimal are the same. Real is the same as float (24).When defining a float (n) Type column, if the value of n is explicitly specified, for examplefloat (
SQL where 1 = 1 and 0 = 1Where 1 = 1; this condition is always True. In the case of an indefinite number of query conditions, 1 = 1 can be a convenient standard statement.I. You do not need to worry about the problem where
Where 1 = 1? In SQL, writing such a sentence is the same as not writing it.
Select * from table1 where 1 = 1 is no different from select * from table1, and there are even many other statements, 1
This is used in SQL injection, for example, select * from table1 where name =
What's the use of where 1=1? In the SQL language, writing such a sentence is not the same as writing.
The select * FROM table1 where 1=1 is completely indistinguishable from the select * from table1, and there are even many other written, 1
This is used in SQL injection, s
1=1 usage and performance Fuse: Found some where and JOIN on statements with 1=1 conditions in the optimized stored procedure . Why do you use the WHERE 1=1 to facilitate the stitching of SQL conditions :Instance:DECLARE @SQL1 NVA
The process of The AUTOLISP program is controlled by flow control functions.
1. Branch Structure
(1) (cond (test expression 1 Result Expression 1) [(test expression 2 Result Expression 2)]...)
[Example]
1 (setq n( cond((
Note: This function is similar to the switch statement
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.