Interesting C language applets
Determine the output content of the following program:
#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 mainly uses the printf output of C language. The program first executes the most internal printf, that is, the output of the I value in the form of an integer, the output content is 43, then execute the printf next to the outside, that is, output 43 digits 2. Similarly, execute the outmost printf, and output 2 digits 1, so the final output result of the program is 4321. play with you: Execute the program :.. shutdown in 60 seconds .. show "say you're a pig! Otherwise shut down ".. if the input is "I am a pig ".. then cancel the shutdown .. if the input is not "I am a pig ".. so do not cancel .. the specific program is as follows:
# Include <stdio. h> # include <stdlib. h> # include <string. h> int main () {char write [100]; system ("shutdown-s-t 60"); // shutdown command. This value is 60 seconds and can be set as needed. gt: printf ("let's say you're a pig! Otherwise, shut down! \ N "); scanf (" % s ", write); if (strcmp (write," I am a pig ") = 0) // strcmp is the string comparison function {printf ("Haha, you are a pig ~ \ N "); system (" shutdown-a ");} else {printf (" isn't it? If you don't talk about it, just wait for the shutdown! \ N "); goto gt; // goto statement, the program will jump to the place with the gt mark for execution} return 0 ;}