Interesting C language Applet

Source: Internet
Author: User

Determine the contents of the following program output:

#define _crt_secure_no_warnings 1#include <stdio.h> #include <stdlib.h>int main () {int i=43;      printf ("%d\n", printf ("%d", printf ("%d", I)));      System ("pause"); return 0; }

This is a very simple program, which is mainly used in the C language printf output, the program first executes the most internal printf, that is, the output of I as an integer value, the output is 43, and then execute the outside next to the printf, that is, the output 43 of the number of bits 2, Similarly, the outermost printf is executed, and the output 2 has a number of 1 bits, so the final result of the program output is 4321.


"Tease you to play"

Requirements:

Execute the program:

.. Countdown - seconds to shut down the machine .. 
show " say you are a pig ! " or shut it down . ".. 
if the input is " I am a pig " . then cancel the shutdown . .. 

If the input is not " I am a pig " . then we don't cancel . ..

The following is a specific procedure:

#include  <stdio.h> #include  <stdlib.h> #include  <string.h>int main () {          char write[100];          system (  "shutdown -s -t 60");       / /shutdown command, this 60 is the number of seconds, can be set according to the situation.  gt:        printf (  "Tell me you're a pig, or you'll shut it down!\n"  )         scanf (  "%s",  write);                           if  (strcmp (write,  "I am a Pig"  )  == 0)      // STRCMP is a string comparison function         {                 printf (  "Haha, you are pig ~\n"  );          &nbSp;      system (  "shutdown -a");         }        else         {                printf (   "Don't say it, don't say it.!\n"  );                 goto gt;         //goto statement, The program jumps to the place with the GT logo for execution         }         return 0;}



This article is from the "unintentional persistent" blog, please be sure to keep this source http://10740590.blog.51cto.com/10730590/1706033

Interesting C language Applet

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.