Analysis of C/C++ B test questions of the 4th Lanqiao cup provincial competition in 2018
1. What day
Title: what day January 1, 2000 is the first day of that year. So, May 4, 2000, is the first day of that year? Note: what needs to be submitted is an integer. Do not fill in any redundant content Answer: 125
#include<stdio.h>
int main()
{
int s=31+29+31+30+4;
printf("%d",s);
return 0;
}
2. Clear code
Title: clear ...
Posted by itguysam on Sat, 08 Jan 2022 16:56:47 +0100
Linux thread synchronization
Linux thread synchronization
1. Mutual exclusion
Ensure that only one thread accesses data at a time.
pthread_mutex_t mut;
//Two initialization methods
mut = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_init(&mut, NULL);
1. Initialization
int pthread_mutex_init (pthread_mutex_t *__mutex,
const pthread_mutexat ...
Posted by br on Sat, 08 Jan 2022 12:20:23 +0100
c language_ Array (super detailed analysis, easy to master)
Catalogue
1. Creation and initialization of array
1.1 creation of array
1.2 initialization of array
1.2.1 initialization of one-dimensional array
1.2.1 initialization of two-dimensional array
2. Some usage methods of array
2.1 calculating array size
2.2 output all contents of the array
3. Storage of array in memory
4. Array out of bou ...
Posted by JesperBisgaard on Sat, 08 Jan 2022 10:41:10 +0100
[C language from 0 (self-study record)] constants and variables
catalogue
1, Constant:
1. Definition method:
2. Data type:
(1) Integer constant:
(2) Real constant:
(3) Character constant:
2, Variable:
1. Define format:
2. Data type:
3. Integer variable input / output:
3, Input (scanf) output (printf) format:
1. Output (printf):
2. Input (scanf):
4, Naming rules:
5, Example:
1, Constant:
...
Posted by silvrfoxx on Sat, 08 Jan 2022 10:11:11 +0100
Linux IPC interprocess communication -- message queue
Message queue is the connection table of messages, which is stored in the kernel. This example mainly realizes inter process communication in the way of message queue. After receiving the message, the receiving end immediately forwards it to the sending end; After sending a message, the sender immediately monitors the message fed back by the re ...
Posted by zako234 on Sat, 08 Jan 2022 10:03:17 +0100
PTA 1018 hammer scissors cloth (20 points) C
preface
Details determine success or failure.
stem
Everyone should be able to play the game of "hammer, scissors and cloth": two people give gestures at the same time, and the winning and losing rules are shown in the figure:
Now the record of the confrontation between the two is given. Please count the number of wins, draws an ...
Posted by totof06 on Sat, 08 Jan 2022 09:33:15 +0100
Super detailed explanation of data types in C language
Super detailed explanation of data types in C language
1, Integer (int, short, long, long)
1. Signed integer Signed integer data types usually include int, short, long and long. Because they are signed types, they should be preceded by signed, but they are usually omitted. That is to say, typing int directly in the code means that they are ...
Posted by MerlinJR on Sat, 08 Jan 2022 03:44:07 +0100
Branch and Loop Statements
Catalog
Branch statement
1. if statement
2. switch statement
Loop statement
1. while statement
2. for loop
3. do...while() loop
Branch statement
Definition: Statements in the code are executed in order from top to bottom. Now you need to check a condition to execute different code according to different conditions, then you need to use ...
Posted by manishsinha27 on Thu, 06 Jan 2022 18:54:26 +0100
Preliminary C language implementation of Sanzi chess
To realize the code of Sanzi chess, we must first understand the game rules of Sanzi chess, that is, both sides play chess in turn. If one party's three pieces form a line, the party wins.
1, Process
The logic of the game is:
1. Establishment of game menu;
2. Create and initialize the chessboard;
3. Print chessboard;
4. The player plays c ...
Posted by Nick Zaccardi on Thu, 06 Jan 2022 09:17:21 +0100
ACM Second Week Training
Question C - Subparagraph Summation
Gives an array of length N, makes Q queries, and queries the sum of all elements in a subsection of length l starting from the first element.
For example, 1 137 9-1, query for subsections and 1 {37 9}-1 with a starting length of 3 for the second element. 3 + 7 + 9 = 19, output 19.
Input
Line 1: A number N ...
Posted by konigwolf on Wed, 05 Jan 2022 22:17:21 +0100