A complex indirect recursion-Common Errors and flaws in C Language beginner code (6)

Source: Internet
Author: User

.

 main(  , & ( n -- > , & , get_nearest( x ) );  

 

 prime_list * get_nearest(  step =  ;             sign = -;            Node * head = NULL ;          ( ! be_prime( x , &+= ( sign = - sign ) * ++

 

 be_prime(  x , Node * * pp )  ( x <=   ( x ==   ( get_remainder( x , pp ) ==  )         

 get_remainder(  x , Node * * pp ) ( * pp == NULL || sqr_less( (*pp) -> prime , x ) )      add_1_prime ( pp ) ;                                 * p = * ( p != ( x % p -> prime ==  = p -> ! sqr_less (  n ,  n * n <

  add_1_prime ( pp ) ;

  sqr_less( (*pp) -> prime , x )

 add_1_prime( Node * * ( * pp == , pp );                             next_p = ( * pp )->prime +  ;            ( !++}

be_prime( next_p , pp )

be_prime( x , & head )

add_1_prime ( pp ) ; 

be_prime( next_p , pp )

 

Get_nearest (step =; sign =-; Node * head = NULL; (create a prime number table () with the largest square of prime numbers not less than x (),! Be_prime (x, & + = (sign =-sign) * ++

 add_1_prime( Node * * ( * pp == , pp );                             ( ( * pp ) ->  : add (   : add (            next_p = ( * pp )->prime +  ;                            ( !++                   

Problem:
Prime Number
In an information and communication Museum in the World Expo Park, visitors can use mobile phones and other terminals to participate in interactive games and play Guess games with virtual characters Kr. Kong.
When an integer X is displayed on the screen, you will receive an unexpected gift if you can give the prime answer closest to it faster than Kr. Kong.

If X itself is a prime number, the answer is X. If there are two prime numbers closest to X, the answer is greater than its prime number.

Next there are N rows, each row has a positive integer X
Output: N rows are output, and each row is the prime number closest to X.

4
22
5
18
8
Output
23
5
19
7

Source: http://www.cnblogs.com/pmer/ "C language beginners code in the Common Errors and flaws" series blog

*/


#include <stdio.h><stdbool.h> prime_list * get_nearest( be_prime( , Node * * get_remainder( , Node * * add_1_prime( Node * * sqr_less ( , add ( , Node * * my_malloc( Node * * my_free( Node * main( , & ( n -- > , & , get_nearest( x ) ); get_nearest( step = ; sign = -; Node * head = NULL ; ( ! be_prime( x , &+= ( sign = - sign ) * ++ be_prime( x , Node * * pp ) ( x <= ( x == ( get_remainder( x , pp ) == ) get_remainder( x , Node * * pp ) ( * pp == NULL || sqr_less( (*pp) -> prime , x ) ) add_1_prime ( pp ) ; * p = * ( p != ( x % p -> prime == = p -> ! sqr_less ( n , n * n < add_1_prime( Node * * ( * pp == , pp ); ( ( * pp ) -> : add ( : add ( next_p = ( * pp )->prime + ; ( !++ add ( prime , Node * **&-> prime =-> next = ** pp = my_malloc( Node * * ( ( * p_p = malloc( (* * p_p) ) ) == my_free( Node ** ( ( temp = p ) !== p->
Related blog

I accidentally found that a Jingle Guo user later studied a blog post on the same issue. I felt that the user reading this article may have some reference value, so I would like to provide the relevant link here :.

Related Article

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.