当前位置:网站首页>Programming training
Programming training
2022-04-23 06:19:00 【#self-discipline#】
There is a polynomial calculator , Huffman codec , The programming of campus tour guide consultation has been uploaded
c Some basic knowledge of language use
1. file
(1)fopen(" route ”," Open mode ”): Open the file to operate on it ; There are several ways to open it r( Open as read-only , The file must exist )r+(r Upgraded version , You can not only read but also write , Be careful r Return first pointer , If the pointer position is not adjusted during the write operation, the original content will be overwritten ; Files still need to exist )w( Open in write only mode , If the file does not exist, it will create a file by itself )w+( Create files in a readable and writable manner , Note that the contents of the file will be emptied and rewritten )a( Open in write only mode , Return end pointer , This allows you to write data after the text data )a+(a Upgrade version of , You can read ); stay ab,wb,rb Is to operate on the binary representation of the file ;
(2)fclose(fp): Close the file after opening it , Increase the running speed ;
(3)fgetc(fp): Read operation , Read fp One character of the position indicated and returns the value , Note that only one character ;
(4)fputc(ch,fp): Write operation , Write a character to fp The position indicated ;
(5)fgets(str,n,fp): Read operation , Read fp After the position n Characters to character array str[] in ;( The last character is set as the cut-off signal \0, So take n You have to set n+1);
(6)fputs(str,fp): take str( Array name ) String input to file fp After the position ,str It can also be directly changed to “ character string ”;
(7)fscanf(fp,"%d%c%s",&a,&b,str): Read operations , take fp After that, the content satisfying the format is assigned to a,b,str;fgets,fgetc Hodgepodge type ;
(8)fprintf(fp,"%d%c%s",a,b,c): Write operation , This kind of writing is very convenient , Input all types of quantities into the file ,fgetc And fgets Hodgepodge type ;
(9)rewind(fp): Put the pointer fp Relocate to the head of the file ;
(10)fwrite(buffer,size,n,fp): It means output n individual size size buffer The data indicated by the pointer to fp After the position ;
(11)fread(buffer,size,n,fp): It means to read fp After n individual size The size of the data to buffer;
(13)fseek(fp, size, a):a=0 Put the file pointer fp Move to the first starting number size Size position ;a=1, Count from the pointer position ;a=2, At the end of the text ;
2. character string
(1)int strcmp(const char *s1, const char *s2): Compare s1,s2, If equal, return 0; if s1>s2 Return greater than 0 Number of numbers ; if s1<s2 Then return less than 0 A number of ;
(2)strcpy(s1,s2): take s2 Copied to the s1;
(3)strcat(s1,s2): take s2 Connect to s1 At the end of ;
/int scanf(char *format[,argument,...]);
double pow(double x,double y)// Find exponential power x Of y The next power
fscanf Read space
feof()
%[^\r\n]
Solve Chinese reading garbled code
Programming :
Need to achieve the function :
(1) Univariate sparse polynomial calculator (2) Maze problem (3) Keyword search (4) Huffman code / / Decoder (5) Campus tour guide consultation
Menu functions :
First class menu : Show the options , Enter the number and compare it to the corresponding secondary menu ;
Two level menu :(1)
(1) Unary sparse polynomial function :
Realization function :① Input univariate sparse polynomial single linked list format ② Realize polynomial addition and subtraction function ③ Realize binomial multiplication , Construct a single linked list for each element of the first single linked list multiplied by all elements of the second single linked list. These single linked lists do not form an array ;
You need a function :
void CreatPolyn (LinkList &P, int m );
void DestroyPolyn (LinkList &P );
void PrintPolyn (LinkList P );
void AddPolyn (LinkList &Pa, LinkList &Pb );
void SubtractPolyn (LinkList &Pa, LinkList &Pb );
void MultiplyPolyn (LinkList &Pa, LinkList &Pb );
(4) Huffman code / Decoder :
Realization function :① Edit text (1 Rewrite text 2 Add characters to the text )② Statistics text character frequency ③ Build a Huffman tree ④ Encode a paragraph of text ⑤ For a binary decoding ;
void count(LinkList2 &L1);// Store the statistical character frequency into L1 In the table ;
(5) Campus tour guide consultation
Realization function :① Read the campus guide map information from the file ( Output information )② Modify the extended function : Open the file and modify it yourself ③ Inquire about any scenic spot ( Enter the attraction number ④ The shortest path of any two vertices
--
版权声明
本文为[#self-discipline#]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230544083255.html
边栏推荐
- Exception handling: grab and throw model
- Pytorch learning record (V): back propagation + gradient based optimizer (SGD, adagrad, rmsporp, Adam)
- Optional best practices
- 9.Life, the Universe, and Everything
- Practical operation - Nacos installation and configuration
- 检测技术与原理
- Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
- Numpy common function table sorting of data processing
- Fundamentals of SQL: first knowledge of database and SQL - installation and basic introduction - Alibaba cloud Tianchi
- Pyqt5 learning (I): Layout Management + signal and slot association + menu bar and toolbar + packaging resource package
猜你喜欢
对比学习论文——[MoCo,CVPR2020]Momentum Contrast for Unsupervised Visual Representation Learning
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
图解numpy数组矩阵
sklearn之 Gaussian Processes
Pytorch Learning record (XIII): Recurrent Neural Network
Framework analysis 1 Introduction to system architecture
Contrôle automatique (version Han min)
线性代数第二章-矩阵及其运算
Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
Kibana search syntax
随机推荐
Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets
Complete example demonstration of creating table to page - joint table query
Algèbre linéaire chapitre 2 - matrice et son fonctionnement
7.Domino piling
Pytorch learning record (XI): data enhancement, torchvision Explanation of various functions of transforms
Use Matplotlib. In Jupiter notebook Pyplot server hangs up and crashes
Pytorch learning record (IX): convolutional neural network in pytorch
SQL injection
Algèbre linéaire chapitre 1 - déterminants
1. Calculate a + B
LDCT图像重建论文——Eformer: Edge Enhancement based Transformer for Medical Image Denoising
Calculation (enter the calculation formula to get the result)
A sharp tool to improve work efficiency
Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)
JDBC connection database
EditorConfig
PyQy5学习(二):QMainWindow+QWidget+QLabel
DBCP usage
3. Continuous integer