当前位置:网站首页>程序設計訓練
程序設計訓練
2022-04-23 06:23:00 【#self-discipline#】
有多項式計算器,哈夫曼編碼譯碼器,校園導遊諮詢的編程已經上傳
c語言使用一些基礎知識
1.文件
(1)fopen("路徑”,"打開方式”):打開文件才能對文件進行操作;打開方式有r(以只讀的方式打開,文件必須存在)r+(r的昇級版,不僅可以進行讀操作也可以進行寫操作,注意r返回首指針,進行寫操作的時候沒有調整指針比特置會覆蓋原先的內容;文件依舊需要存在)w(以只寫的方式打開,若文件不存在會自行創建一個文件)w+(以可讀可寫的方式進行創建文件,注意文件內容會清空重寫)a(以只寫的方式打開,返回末尾指針,這就可以在文數據的後面寫入數據)a+(a的昇級辦版,可以進行讀的操作);在ab,wb,rb則是對文件的二進制錶示進行操作;
(2)fclose(fp):打開文件操作完後要關閉文件,提高運行速度;
(3)fgetc(fp):讀取操作,讀取fp所指比特置的一個字符並返回值,注意只能一個字符;
(4)fputc(ch,fp):寫入操作,寫入一個字符到fp所指比特置;
(5)fgets(str,n,fp):讀取操作,讀取fp比特置後的n個字符到字符數組str[]中;(最後一個字符設定為截止信號\0,所以要取n個就要設定n+1);
(6)fputs(str,fp):將str(數組名)的字符串輸入到文件fp比特置後,str也可直接改為“字符串”;
(7)fscanf(fp,"%d%c%s",&a,&b,str):讀操作,將fp後滿足格式的內容依次賦值給a,b,str;fgets,fgetc的雜燴型;
(8)fprintf(fp,"%d%c%s",a,b,c):寫入操作,這種寫入十分方便,將各類型的量都輸入到文件中,fgetc與fgets的雜燴型;
(9)rewind(fp):將指針fp重新定比特到文件首端;
(10)fwrite(buffer,size,n,fp):意思是輸出n個size大小buffer指針所指的數據到fp比特置後;
(11)fread(buffer,size,n,fp):意思是讀入fp後的n個size大小的數據到buffer;
(13)fseek(fp, size, a):a=0將文件指針fp移動到首開始數size大小比特置;a=1,從指針比特置開始數;a=2,文末比特置;
2.字符串
(1)int strcmp(const char *s1, const char *s2):比較s1,s2,若相等則返回0;若s1>s2則返回大於0的數;若s1<s2則返回小於0的一個數;
(2)strcpy(s1,s2):將s2複制到s1;
(3)strcat(s1,s2):將s2連接到s1的末尾;
/int scanf(char *format[,argument,...]);
double pow(double x,double y)//求指數幂x的y次幂
fscanf讀空格
feof()
%[^\r\n]
解决中文讀取亂碼
程序設計編程:
需要達到功能:
(1)一元稀疏多項式計算器(2)迷宮問題(3)關鍵字查找(4)哈夫曼編碼/ / 譯碼器(5)校園導遊諮詢
菜單函數:
一級菜單:展示各選項,輸入數字比較到對應的二級菜單;
二級菜單:(1)
(1)一元稀疏多項式函數:
實現功能:①輸入一元稀疏多項式的單鏈錶格式②實現多項式相加减函數③實現二項相乘,為第一個單鏈錶的每個元素乘第二個單鏈錶所有元素構造一個單鏈錶並未這些單鏈錶構造成數組;
需要函數:
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)咍夫曼編碼/譯碼器:
實現功能:①編輯文本(1重新寫入文本2增加文本字符)②統計文本字符頻率③構建咍夫曼樹④為一段文字編碼⑤為一段二進制譯碼;
void count(LinkList2 &L1);//將統計的字符頻率存入L1錶中;
(5)校園導遊諮詢
實現功能:①從文件中讀入校園導遊圖信息(輸出信息)②修改擴充功能:打開文件自行修改③查詢任一景點相關信息(輸入景點號碼④任意兩個頂點的最短路徑
--
版权声明
本文为[#self-discipline#]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230544083255.html
边栏推荐
- Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
- Class loading and classloader understanding
- Treatment of tensorflow sequelae - simple example record torch utils. data. dataset. Picture dimension problem when rewriting dataset
- Pytorch learning record (7): skills in processing data and training models
- MySQL basic madness theory
- Usage scenario of copyonwritearraylist
- Substring Inversion (Easy Version)
- Fundamentals of SQL: first knowledge of database and SQL - installation and basic introduction - Alibaba cloud Tianchi
- Why does the subscript of the array start from 0 instead of 1?
- Best practices for MySQL storage time
猜你喜欢
Addition, deletion, modification and query of MySQL table
对比学习论文——[MoCo,CVPR2020]Momentum Contrast for Unsupervised Visual Representation Learning
线性代数第二章-矩阵及其运算
Pytorch learning record (7): skills in processing data and training models
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention
Unsupervised denoising - [tmi2022] ISCL: dependent self cooperative learning for unpaired image denoising
Linear algebra Chapter 1 - determinant
A general U-shaped transformer for image restoration
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images
无监督去噪——[TMI2022]ISCL: Interdependent Self-Cooperative Learning for Unpaired Image Denoising
随机推荐
PHP processing JSON_ Decode() parses JSON stringify
MySQL basic madness theory
How to grow at work
Practical operation - Nacos installation and configuration
Event listener
Customized communication between threads (reentrantlock)
Linear algebra Chapter 2 - matrices and their operations
Anaconda installed pyqt5 and pyqt5 tools without designer Exe problem solving
線性代數第二章-矩陣及其運算
Calculation (enter the calculation formula to get the result)
7.Domino piling
Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi
A general U-shaped transformer for image restoration
Delete and truncate
Integration and induction of knowledge points of automatic control principle (Han min version)
Kalman filter and inertial integrated navigation
Development environment EAS login license modification
Gaussian processes of sklearn
常用编程记录——parser = argparse.ArgumentParser()
Rsync for file server backup