Enlightenment: the beginning of C note taking (Part one)

Time:2021-1-25

 

(it’s all dry goods. If you are a beginner of C language and understand the following recommended topics, you will be ahead of your classmates!) ——-(later supplement)

(if you can’t understand some code, please write your question in the comment area, and I will reply to you!)

 

This is some of the more difficult topics when I first learned. I recommend these topics to you. I don’t need to do some useless questions, but I also waste some time. I don’t need to do more mindless questions. Although it’s very cool, it’s not good for improvement…

 

For example, this question: https://www.luogu.com.cn/problem/P1000

The answer of the big guy on the list is, but…… If your idea is to be ranked second, it is highly recommended to write a wave

 

Question making process:

Do the question before the examination must be careful, observe what some restrictions, the key words down. (the restriction must be complete, otherwise it will waste a lot of time in the future.).
Be sure to bring the draft paper and express your thoughts in simple C language in the draft paper,
After writing, follow your own way of thinking according to the restrictions. If there are too many restrictions, use a few more examples
To replace and correct mistakes.
Finally, code quickly according to the content of the paper.
 
As we all know, the most important thing is the ability to debug code. What we usually brush questions is the ability to debug code. If you can debug code problems quickly, you can buy more time to brush the next question. Don’t flinch when you encounter difficulties. Remember that when we brush questions at that time, a topic had to be changed for a few days, and ten thousand grass mud horses galloped by,,, From time to time…..
 

Tips:

① Sometimes the train of thought is right, I feel it is right, but I just can’t get full marks. That may be the subject card your point, the scope of a little wider, for beginners, want to open as much as open. Open in the main function, big data will burst stack, so it is recommended to open the array outside the main function.
 
② There is a cycle of this grammar must be used well, because the computer is dead, not lazy, only do stupid things, so sometimes we do not need to help him think, tired himself.
Beginners must change their thinking and use computer thinking to think about problems. Machines are not as smart as you are.
Take care, brother. I’ll shave first! )

 

 
Example:
 

For this problem, I just began to think, what mathematical formula should be used to calculate the weekend separately, and finally seven to eight. After the death of trouble, look at the answer, my God!!! Really simple, let the computer cycle, give him a limit, give him a termination order, the end of the problem!
Examine the topic carefully and find out what the topic really wants you to do. Don’t be confused by the topic.
After reading a little tip, let’s do this first https://www.luogu.com.cn/problem/P1424
 
 

Topic recommendation

At the beginning of my study, I was surrounded by this problem. At that time, I found the minimalist code on the Internet and wrote it with the pointer. At that time, I was confused. When I got to the back of the problem, I knew it was very simple. So I recommend this problem to you.

http://www.51cpc.com/problem/1059

Attached is a personal explanation:

 https://www.cnblogs.com/Attacking-vincent/p/12720837.html

This question is about acill code. I was a little strange to this thing at that time.

Here’s a little tip (for those who don’t remember acill code and don’t have a net, mostly in the exam), you can do this:

#include
int main(){
    char ch='a';
    printf("%d\n",ch);
    return 0;
}

Pay attention to a praise!

 

https://www.luogu.com.cn/problem/P1914

This problem is to use the idea of taking module. With taking module, you can turn the related information of a straight line into a ring.

#include
#include
int a[1000];
int main(){
    int n,i;
    char a[1000];
    scanf("%d%s",&n,a);
    for(i=0;a[i]!='
#include
#include
int a[1000];
int main(){
int n,i;
char a[1000];
scanf("%d%s",&n,a);
for(i=0;a[i]!='\0';i++){
printf("%c",(a[i]-'a'+n)%26+'a');
}
return 0;
}
';i++){ printf("%c",(a[i]-'a'+n)%26+'a'); } return 0; }

 

Tips:

① When it comes to identifying the number of words, use spaces to distinguish. (if you learn C + +, you don’t have to write it.)

Example well done Oh, no knowledge points can leave a message Oh, I am sure to answer in time.

Attach title http://www.51cpc.com/problem/1061

Attach a personal explanation https://www.cnblogs.com/Attacking-vincent/p/12721966.html

② Only odd numbers are prime numbers.

③ To understand the use of existing data, do not complicate the data, can reduce variables to reduce variables!

 
 

Problem solving method

bubble sort
 
 
It repeatedly visits the element column to be sorted, compares two adjacent elements in turn, and exchanges them if the order (such as from large to small, Z to a) is wrong. The work of visiting elements is repeated until no adjacent elements need to be exchanged, that is, the element column has been sorted. (from Baidu Encyclopedia)
 
 
Selection sorting method
 
Its working principle is to select the smallest (or largest) element from the data elements to be sorted each time, store it at the beginning of the sequence, and then continue to find the smallest (or largest) element from the remaining unsorted elements, and then put it at the end of the sorted sequence. And so on, until all the data elements to be sorted are finished. (from Baidu Encyclopedia)
Personal feeling is the upgrade of bubble sort.
 
If there is such a decimal point, we should pay attention to the accuracy to prevent the loss of accuracy.
 

Related concepts of recursive function

For recursive function, it is to call the function designed by ourselves, which is equivalent to loop function;
It can be divided into participation and non participation
 

Recursive example:

 
If you have done this problem, please do it again. It’s really classic
https://www.imooc.com/code/5504
Cumulative number of words remembered
 
After reading this, let’s look at another topic
 
https://www.imooc.com/code/5510
 
Do recursive problem, we can not be too anxious, first in the draft paper to write a good cumulative algorithm, and then call the function. The reason why the output is reversed is that to know the number of peaches picked first, we have to go through the ninth day’s program to get the answer in reverse, and use the characteristics of computer to calculate.
 
 

A new digital reverse order output method!!

This idea was praised by the teacher at the beginning. Now I recommend it to you. You should make good use of it!!
 
 
END?????
How does it feel to see it here???
 
what??? It’s too simple. Everyone can do it.
Let’s take a look at the code I met in the next part!
 
If you don’t understand this article, please leave a message in the comment area!
I will revise it and say it in more detail. Thank you for your attention!
 
Enlightenment: the beginning of C note taking (Part 2) https://www.cnblogs.com/Attacking-vincent/p/12721609.html
 
 
Give me a compliment before you go!

Recommended Today

JS function

1. Ordinary function Grammar: Function function name (){ Statement block } 2. Functions with parameters Grammar: Function function name (parameter list){ Statement block } 3. Function with return value Grammar: Function function name (parameter list){ Statement block; Return value; } Allow a variable to accept the return value after calling the function Var variable name […]