C language for multi-layer dynamic memory allocation, two-dimensional array
One-dimensional Array Dynamic Memory Allocation
First, let's start with a simple dynamic memory allocation.
#include "stdio.h"
#include "stdlib.h"
#define N 5
int main() {
int* arr = (int*)malloc(sizeof(int)*N);
for(int i = 0; i < N; i++) {
arr[i] = i * i;
}
for(int i = 0; i < N; i++) {
printf("\n% ...
Posted by Daniel Exe on Thu, 09 Sep 2021 10:14:12 -0700
[C language] stack and queue
The code in this paper is basically implemented by C language, except for the code implementation of "2.3.4 Leetcode496".
1. Queue
1.1 nature of queue
FIFO: first in, first out. The team goes out first and the team goes out at the end.
1.2 general queue
1.2.1 code implementation of ordinary queue
#include <stdio.h>
#includ ...
Posted by logicsound on Wed, 08 Sep 2021 01:45:14 -0700
PAT grade B exercise 1034 four operations of rational numbers
Title:
Enter two fractional rational numbers in the form of A1 / B1 and A2 / B2 in one line, where the numerator and denominator are all integers within the integer range, the negative sign can only appear in front of the numerator, and the denominator is not 0.
Output format:
Output the sum, difference, product and quotient of two rational ...
Posted by stopblackholes on Tue, 07 Sep 2021 13:36:26 -0700
Two-dimensional arrays and secondary pointers in function parameters
Two-dimensional arrays and secondary pointers in function parameters
Preface:
_Two-dimensional arrays are passed through a second-order pointer in a template function given by leetcode, which also gives an array of Row rows and Col columns. a[i][j] is often used directly in the function to traverse each element of the two-dimensional array.A ...
Posted by shak123 on Tue, 07 Sep 2021 09:45:01 -0700
[vernacular design pattern, uncover secrets
problem
Suppose you are developing a logistics management application. The original version could only handle truck transportation, so most of the code was in a class called truck.
After a while, this app became extremely popular. You can receive more than ten requests from shipping companies every day, hoping that the application can su ...
Posted by Xyphon on Mon, 06 Sep 2021 19:16:29 -0700
PAT class a graph theory
Test site
1. Various deformations of Dijkstra 2. Connectivity, judging the number of connected blocks 3. Hierarchical traversal 4. Ergodic properties of edges
Foundation preparation - Dijkstra I
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 510;
int n, m;
int g[N][N];
...
Posted by shatner on Mon, 06 Sep 2021 12:33:50 -0700
Summary of C++11 Features
C++11
C++11 can be understood as a new language and is simpler and more efficient.Memory management and threading framework were introduced. While maintaining efficiency, better abstraction mechanisms are supported. Maintain performance while improving code security and productivity. Previous C++ versions could be considered C++98/03. Mode ...
Posted by aynsoft on Mon, 06 Sep 2021 09:53:57 -0700
Test Page 2 on Game Development (C++)
Test Page 2 on Game Development (C++)
1. The function of the following prim function is to decompose the prime factor.What should be in parentheses?
void prim(int m, int n)
{
if (m >= n)
{
while ( ) n++;
( );
prim(m, n);
cout << n << endl;
}
}
A: m%n, m/=n.
What ...
Posted by micki on Mon, 06 Sep 2021 09:47:28 -0700
[Questions] AcWing 1566. Graduate Enrollment
1566. Graduate Enrollment
Theme transmission: AcWing 1566. Graduate Enrollment
It is said that,
2011
2011
In 2011, Zhejiang Province has about
100
100
100 Graduate Hospitals Ready to ...
Posted by jamiet757 on Mon, 06 Sep 2021 09:33:18 -0700
visual studio code under Windows system uses cmake to build a complete c + + Project
catalogue
1, Construction of development environment:
2, Code project practice
3, The following problems and solutions may occur:
1, Construction of development environment:
cmake Baidu online disk link:
Link: https://pan.baidu.com/s/1CFQnlU4AwrqAYiMYyGHdmw Extraction code: ab7a
Download GCC compiler mingw64.zip under wi ...
Posted by DaRkZeAlOt on Sun, 05 Sep 2021 18:54:04 -0700