# If, # comprehensive application of ifdef and # ifndef

Source: Internet
Author: User

1 # include <stdio. h>
2
3 # define MAX
4
5 # define MAXIMUM (x, y) x> y? X: y
6 # define MINIMUM (x, y) x <y? X: y
7
8 int main ()
9 {
10 int a = 10, B = 20;
11
12 # ifdef MAX
13 printf ("\ 40: The larger one is % d \ n", MAXIMUM (a, B ));
14 # else
15 printf ("\ 40: The lower one is % d \ n", MINIMUM (a, B ));
16 # endif
17
18
19 # ifndef MIN
20 printf ("\ 40: The lower is % d \ n", MINIMUM (a, B ));
21 # else
22 printf ("\ 40: The larger one is % d \ n", MAXIMUM (a, B ));
23 # endif
24
25 # undef MAX
26 # ifdef MAX
27 printf ("\ 40: The larger one is % d \ n", MAXIMUM (a, B ));
28 # else
29 printf ("\ 40: The lower one is % d \ n", MINIMUM (a, B ));
30 # endif
31
32
33 # define MIN
34 # ifndef MIN
35 printf ("\ 40: The lower one is % d \ n", MINIMUM (a, B ));
36 # else
37 printf ("\ 40: The larger one is % d \ n", MAXIMUM (a, B ));
38 # endif
39 return 0;
40
41}



From zhengmian

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.