Category:C

  • The method of realizing recursive function in C + +

    Time:2020-7-13

    Generally speaking, recursive functions call themselves. This has great advantages, code is very convenient and concise, the complex regular operation to the computer to do. 1. First, define the problem. Recursion needs to set a function, and then it can be executed repeatedly. 2. Change the problem to a formula. If the sum of factorials […]

  • Printf print color

    Time:2020-7-13

    int main(void) { printf(“\033[31;1m haha\n”); printf(“\033[32;1m haha\n”); printf(“\033[33;1m haha\n”); printf(“\033[34;1m haha\n”); printf(“\033[35;1m haha\n”); printf(“\033[36;1m haha\n”); printf(“\033[37;1m haha\n”); return 0; } result  

  • C serial 10 char type printing, two exception portable types

    Time:2020-7-11

    1、 Print char characters #include #pragma warning(disable:4996) ​ int D10_1_PrintCharacter(void) { char ch; ​ printf(“Please enter a character:\n”); //ch = 45; scanf(“%c”, &ch); printf(“The code for %c is %d\n”, ch, ch); ​ return 0; } When printing, I found that scanf is an unsafe function. After Baidu, I declare a statement to solve the problem […]

  • C language array stack implementation template

    Time:2020-7-11

    In this paper, we share the C language array stack template specific code, for your reference, the specific content is as follows SeqStack.h #pragma once #define MAX_SIZE 1024 typedef struct SEQSTACK { void* data[MAX_SIZE]; int size; }SeqStack; SeqStack* Init_ Seqstack(); // initialize stack void Push_ Seqstack (seqstack * stack, void * data); // put on […]

  • C language uses template to realize simple stack class

    Time:2020-7-10

    In this paper, we share the C language for you to use the template to achieve a simple stack class (array and single linked list), for your reference, the specific content is as follows The main function is to realize a list of last in first out, which has the basic functions of stack in, […]

  • C / C + + Programming Notes: C language to see the game, Xiaobai practice project (source sharing)

    Time:2020-7-10

    This article share to see the title is written for beginners, learn better small partners can also add some knowledge such as automatic algorithm, hope to help you! Well, when all our preparations are done, we can write our c language and watch the game again and again! In fact, this game design is really […]

  • C + + stack class template implementation code

    Time:2020-7-9

    Recently, we reviewed the data structure, involving the implementation of the stack. Through the class template, we can make the storage data type of the stack more flexible. Here is the implementation code of the stack: #ifndef MYSTACK_H #define MYSTACK_H #include <iostream> using namespace std; template <typename T> class MyStack { public: MyStack(int size); ~MyStack(); […]

  • Data structure and algorithm (1)

    Time:2020-7-9

    The measurement method of algorithm efficiency is as follows 1. After the event statistical method: through the designed test program and data, using the computer timer to compare the running time of the programs compiled by different algorithms, so as to determine the efficiency of the algorithm. Defect: it is based on and prepared a […]

  • C + + using linked list template class to achieve simple queue

    Time:2020-7-8

    This example for you to share the C + + use of linked list template class to achieve a specific code for your reference, the specific content is as follows Design idea:The template class is declared and implemented in myqueue. H. Firstly, the structure of the node is defined, including data and pointer field. In […]

  • Data structure and algorithm (2) linear table 1

    Time:2020-7-8

    Linear table: Definition: a finite sequence of zero or more data elements. First of all, it is a sequence, that is to say, elements come first, then come If there are more than one element, the first element has no precursor, the last element has no successor, and other elements have and only one precursor […]

  • C + + using template to realize single linked list

    Time:2020-7-7

    This example for you to share with the template to achieve a single linked list, for your reference, the specific content is as follows Don’t say much, just code it #include <iostream> using namespace std; template<typename E> class CLink; template<typename T> class Node { friend class CLink<T>; public: /* Constructors and destructors generally do not […]

  • C serialization 11 – portable types, double, float

    Time:2020-7-7

    1、 Examples of portable types 1. What if the system does not support “precise width integer type”? Minimum width type: some type names guarantee that the type represented must be the smallest integer type with at least the specified width. Use the types defined above, for example:int_least8_tIs an alias that can hold the smallest width […]