6.27-6.29 舊c語言

#include<stdio.h>
struct stu
{int num;float score;struct stu *next;
};
void main()
{struct stu a,b,c,*head;//靜態鏈表a.num = 1;a.score = 10;b.num = 2;b.score = 20;c.num = 3;c.score = 30;head = &a;a.next = &b;b.next = &c;do{printf("%d,%5.1f\n",head->num,head->score);head = head->next;}while(head != NULL);
}

在這里插入圖片描述
在這里插入圖片描述

#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct stu)
int n;
struct stu
{int num;float score;struct stu *next;
};
struct stu *creat()//建立動態鏈表
{struct stu *p1,*p2,*head;p1 = p2 = (struct stu *)malloc(LEN);printf("input num:\n");scanf("%d",&p1->num);printf("input score:\n");scanf("%f",&p1->score);head = NULL,n = 0;while(p1->num != 0){n++;if(n == 1){head = p1;}else{p2->next = p1;}p2 = p1;//p1 = (struct stu *)malloc(LEN);printf("input num:\n");scanf("%d",&p1->num);printf("input score:\n");scanf("%f",&p1->score);}p2->next = NULL;return head;}
void print(struct stu *head)
{struct stu *p;printf("there are %d record stu\n",n);p = head;if(head != NULL){do{printf("num = %d,score = %f\n",p->num,p->score);p = p->next;}while(p);//直到p為空結點退出循環}
}
void main()
{struct stu *p;p = creat();print(p);
}

在這里插入圖片描述

#include<stdio.h>//增刪改查
#include<stdlib.h>
#define LEN sizeof(struct stu)
struct stu *del(struct stu *head,int n);
struct stu *creat();
void print(struct stu *head);
int n;
struct stu
{int num;float score;struct stu *next;
};
struct stu *del(struct stu *head,int m)
{struct stu *p1,*p2;p1 = head;if(head == NULL)//判斷是否為空鏈表{printf("this is kong node\n");return NULL;}while(p1->num != m && p1->next != NULL)//刪除的值不是當前結點,且當前結點不為尾節點{p2 = p1;p1 = p1->next;}if(p1->num == m)//找到節點{if(p1 == head)//如果當前節點為頭結點{head = p1->next;}else//此時為普通結點{p2->next = p1->next;}printf("del NO:%d success!\n",m);n = n-1;}else{printf("%d no found!\n",n);}return head;
}
struct stu *creat()
{struct stu *p1,*p2,*head;p1 = p2 = (struct stu *)malloc(LEN);printf("input num:\n");scanf("%d",&p1->num);printf("input score:\n");scanf("%f",&p1->score);head = NULL,n = 0;while(p1->num != 0){n++;if(n == 1){head = p1;}else{p2->next = p1;}p2 = p1;p1 = (struct stu *)malloc(LEN);printf("input num:\n");scanf("%d",&p1->num);printf("input score:\n");scanf("%f",&p1->score);}p2->next = NULL;return head;}
void print(struct stu *head)
{struct stu *p;printf("there are %d record stu\n",n);p = head;if(head != NULL){do{printf("num = %d,score = %f\n",p->num,p->score);p = p->next;}while(p);}
}
void main()
{struct stu *stu,*p;int k;stu = creat();p = stu;print(p);printf("del num is:\n");scanf("%d",&k);print(del(p,k));
}

在這里插入圖片描述
在這里插入圖片描述

#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct stu)
struct stu *del(struct stu *head,int n);
struct stu *creat();
void print(struct stu *head);
struct stu *inser(struct stu *head,struct stu *ins);
struct stu *lookfor(struct stu *head,struct stu *look);
struct stu *wrilink(struct stu *head,struct stu *stu4);
struct stu
{int num;float score;struct stu *next;
};
int n;
struct stu *wrilink(struct stu *head,struct stu *stu4)
{struct stu *p;p = head;if(head == NULL){printf("無數據可修改!\n");}else{while(p != NULL){if(p->num == stu4->num){p->score = stu4->score;}p = p->next;}}return head;
}
struct stu *lookfor(struct stu *head,struct stu *look)
{struct stu *p;p = head;if(p == NULL){printf("沒有數據!\n");}else{while(p != NULL){if(p->num == look->num){printf("找到第%d個數據,分數為%f\n",p->num,p->score);}p = p->next;}}return head;
}
struct stu *inser(struct stu *head,struct stu *ins)
{struct stu *p1,*p2,*p0;p0 = ins;p1 = head;if(head == NULL){head = p0;p0->next = NULL;}else{while((p0->num >p1->num) && (p1->next != NULL)){p2 = p1;p1 = p1->next;}if(p0->num <= p1->num){if(p1 == head){head = p0;}else{p2->next = p0;}p0->next = p1;}else{p1->next = p0;p0->next = NULL;}n = n+1;return head;}
}
struct stu *del(struct stu *head,int m)
{struct stu *p1,*p2;p1 = head;if(head == NULL){printf("this is kong node\n");return NULL;}while(p1->num != m && p1->next != NULL){p2 = p1;p1 = p1->next;}if(p1->num == m){if(p1 == head){head = p1->next;}else{p2->next = p1->next;}printf("del NO:%d success!\n",m);n = n-1;}else{printf("%d no found!\n",n);}return head;
}
struct stu *creat()
{struct stu *p1,*p2,*head;p1 = p2 = (struct stu *)malloc(LEN);printf("input num:\n");scanf("%d",&p1->num);printf("input score:\n");scanf("%f",&p1->score);head = NULL,n = 0;while(p1->num != 0){n++;if(n == 1){head = p1;}else{p2->next = p1;}p2 = p1;p1 = (struct stu *)malloc(LEN);printf("input num:\n");scanf("%d",&p1->num);printf("input score:\n");scanf("%f",&p1->score);}p2->next = NULL;return head;}
void print(struct stu *head)
{struct stu *p;printf("there are %d record stu\n",n);p = head;if(head != NULL){do{printf("num = %d,score = %f\n",p->num,p->score);p = p->next;}while(p != NULL);}
}
void main()
{struct stu *stu,*p,stu2,stu3,stu4;int k;stu = creat();p = stu;print(p);printf("del num is:\n");scanf("%d",&k);print(del(p,k));printf("insert into the num:");scanf("%d",&stu2.num);printf("insert into the score:");scanf("%f",&stu2.score);p = inser(stu,&stu2);print(p);printf("請輸入查找的數據是:");scanf("%d",&stu3.num);lookfor(stu,&stu3);printf("請輸入修改的學號:");scanf("%d",&stu4.num);printf("請輸入修改的學號數據:");scanf("%f",&stu4.score);p = wrilink(stu,&stu4);print(p);
}

typedef 聲明新的類型名來代替已有的類型名,有利于程序通用與移植

#include<stdio.h>
typedef struct
{int year;int month;int day;
}date;
void main()
{date da;da.year = 1995;da.month = 8;da.day = 9;printf("%d--%d--%d\n",da.year,da.month,da.day);
}
#include<stdio.h>
typedef int num[100];//聲明um為整型數組類型
void main()
{num n = {0};printf("%d\n",sizeof(n));
}
#include<stdio.h>
typedef void (*p)();
void fun()
{printf("funny\n");
}
void main()
{p p1;p1 = fun;//函數指針指向函數的入口p1();
}

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/37736.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/37736.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/37736.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Flink 從入門到放棄

0 寫在前面 程序員闖蕩江湖的一生都在與數據打交道&#xff0c;初入江湖時基于 MySQL 的 CRUD&#xff0c;漸入佳境后利用 Redis 實現查詢加速及分布式控制&#xff0c;本質上都是數據處理&#xff1b;無論主動/被動&#xff0c;都在利用數據來達成業務/技術目的。自然而然的&a…

javaSE知識點整理總結(下)、MySQL數據庫

目錄 一、異常 1.常見異常類型 2.異常體系結構 3.異常處理 &#xff08;1&#xff09;finally &#xff08;2&#xff09;throws 二、JDBC 1.JDBC搭建 2.執行SQL語句兩種方法 三、MySQL數據庫 1.ddl 2.dml 3.dql &#xff08;1&#xff09;字符函數 &#xff08;…

Linux開發講課22---I2C讀寫 EEPROM 實驗(含代碼)

EEPROM 是一種掉電后數據不丟失的存儲器&#xff0c;常用來存儲一些配置信息&#xff0c;以便系統重新上電的時候加載之。 EEPOM 芯片最常用的通訊方式就是 I2C 協議&#xff0c;本小節以 EEPROM的讀寫實 驗為大家講解 STM32 的 I2C 使用方法。實驗中 STM32 的 I2C 外設采用主模…

防止它人代碼調試?分享 1 段優質 JS 代碼片段!

大家好&#xff0c;我是大澈&#xff01; 本文約 600 字&#xff0c;整篇閱讀約需 1 分鐘。 每日分享一段優質代碼片段。 今天分享一段 JS 代碼片段&#xff0c;是防止代碼被調試或篡改的基礎。 老規矩&#xff0c;先閱讀代碼片段并思考&#xff0c;再看代碼解析再思考&#…

如何輕松解決復雜文檔格式轉換問題

上周&#xff0c;我遇到了一個棘手的問題&#xff1a;需要將一大堆PDF文件轉換成可編輯的Word文檔&#xff0c;時間緊迫&#xff0c;手動轉換根本來不及。朋友推薦我使用了一個網站——xuelin.cc&#xff0c;這個網站不僅提供強大的AI對話功能&#xff0c;還能輕松完成各種文檔…

Hadoop3:Yarn框架的三種調度算法

一、概述 目前&#xff0c;Hadoop作業調度器主要有三種&#xff1a;FIFO、容量&#xff08;Capacity Scheduler&#xff09;和公平&#xff08;Fair Scheduler&#xff09;。Apache Hadoop3.1.3默認的資源調度器是Capacity Scheduler。 CDH框架默認調度器是Fair Scheduler。 …

改機軟件有哪些?實現一鍵新機、改串號、改IMEI和手機參數的需求 硬改手機軟件,新機環境模擬 設備偽裝,一鍵改機,一鍵復原

這次針對可以直接開端口修改參數的機型做一些工具解析 前面接觸合作過很多工作室。其中很多工作室對于各自軟件的跳驗證有各自的需求。 一個機型各項參數一般有IMEI WiFi 藍牙 sn psb ESN等等。 針對這些參數的修改首先要明白各自軟件檢測的具體是哪些參數來驗證。 對于常用…

#HDC2024 心得分享#主題演講學習-加入鴻蒙生態正當時

一、主題演講學習心得 通過本次主題演講的聆聽與學習&#xff0c;我們在猜出中和不太確定的相關內容紛紛呈現。比如鴻蒙內核與HarmonyOS Next獲得行業內最高等級的安全認證&#xff1b;盤古大模型、小藝智能體、意圖理解與分發框架等構筑的AI、AIGC能力對HarmonyOS Next及原生…

MySQL高級-索引-使用規則-覆蓋索引回表查詢

文章目錄 1、覆蓋索引1.1、查看索引1.2、刪除單列索引 idx_user_pro1.3、查詢 profession軟件工程 and age31 and status01.4、執行計劃 profession軟件工程 and age31 and status01.5、執行計劃 select id,profession,age,status1.6、執行計劃 select id,profession,age,statu…

Transformer教程之多頭自注意力機制

大家好&#xff0c;今天我們要聊一聊Transformer中的一個核心組件——多頭自注意力機制。無論你是AI領域的新手&#xff0c;還是深度學習的老鳥&#xff0c;這篇文章都會幫助你更深入地理解這個關鍵概念。我們會從基礎開始&#xff0c;逐步深入&#xff0c;最終讓你對多頭自注意…

軟考《信息系統運行管理員》-1.3信息系統運維的發展

1.3信息系統運維的發展 我國信息系統運維的發展總體現狀 呈現三個“二八現象” 從時間周期看&#xff08;開發流程&#xff09;從信息系統效益看&#xff08;消息體現為“用好”&#xff09;從資金投入看&#xff08;重開發&#xff0c;輕服務&#xff09; 信息系統運維的發…

Codeforces Beta Round 32 (Div. 2, Codeforces format) D. Constellation 題解 枚舉

Constellation 題目描述 A star map in Berland is a checked field n m nm nm squares. In each square there is or there is not a star. The favorite constellation of all Berland’s astronomers is the constellation of the Cross. This constellation can be for…

JAVA高級進階13單元測試、反射、注解

第十三天、單元測試、反射、注解 單元測試 介紹 單元測試 就是針對最小的功能單元(方法)&#xff0c;編寫測試代碼對其進行正確性測試 咱們之前是如何進行單元測試的&#xff1f; 有啥問題 &#xff1f; 只能在main方法編寫測試代碼&#xff0c;去調用其他方法進行測試。 …

頁面開發感想

頁面開發 1、 前端預覽 2、一些思路 2.1、首頁自定義element-plus的走馬燈 :deep(.el-carousel__arrow){border-radius: 0%;height: 10vh; }需要使用:deep(標簽)才能修改樣式 或者 ::v-deep 標簽 2.2、整體設計思路 <template><div class"card" style&…

【ChatBI】text2sql-不需要訪問數據表-超輕量Python庫Vanna快速上手,對接oneapi

oneapi 準備 首先確保你有oneapi &#xff0c;然后申請 kimi的api 需要去Moonshot AI - 開放平臺 然后添加一個api key 然后打開oneapi的渠道界面&#xff0c;添加kimi。 然后點擊 測試&#xff0c; 如果能生成響應時間&#xff0c;就是配置正確。 然后創建令牌 http:…

Vllm Offline 啟動

Vllm Offline 啟動 Vllm Offline 啟動&#xff0c;設置環境變量&#xff0c; TRANSFORMERS_OFFLINE1reference: https://github.com/vllm-project/vllm/discussions/1405

Linux shell編程學習筆記60:touch命令

0 前言 在csdn技能樹Linux入門的練習題中&#xff0c;touch是最常見的一條命令。這次我們就來研究它的用法。 1 touch命令的功能、格式和選項說明 我們可以使用touch --help命令查看touch命令的幫助信息。 [purpleendurer bash ~ ]touch --help Usage: touch [OPTION]... …

MATLAB-NGO-CNN-SVM,基于NGO蒼鷹優化算法優化卷積神經網絡CNN結合支持向量機SVM數據分類(多特征輸入多分類)

NGO-CNN-SVM&#xff0c;基于NGO蒼鷹優化算法優化卷積神經網絡CNN結合支持向量機SVM數據分類(多特征輸入多分類) 1.數據均為Excel數據&#xff0c;直接替換數據就可以運行程序。 2.所有程序都經過驗證&#xff0c;保證程序可以運行。 3.具有良好的編程習慣&#xff0c;程序均…

【Android面試八股文】Activity A跳轉B,B跳轉C,A不能直接跳轉到C,A如何傳遞消息給C?

文章目錄 1. 使用Intent傳遞消息2. 使用全局單例類(Singleton)3. 使用靜態變量4. 使用Application全局靜態變量5. 使用 Android系統剪切板(Clipboard)6. 本地化存儲方式6.1 使用SharedPreferences6.2 使用File文件存儲方式傳遞消息6.3 使用SQLite數據庫方式傳遞消息7. 使用廣…

【Spring Boot】Java 的數據庫連接模板:JDBCTemplate

Java 的數據庫連接模板&#xff1a;JDBCTemplate 1.JDBCTemplate 初識1.1 JDBC1.2 JDBCTemplate 2.JDBCTemplate 實現數據的增加、刪除、修改和查詢2.1 配置基礎依賴2.2 新建實體類2.3 操作數據2.3.1 創建數據表2.3.2 添加數據2.3.3 查詢數據2.3.4 查詢所有記錄2.3.5 修改數據2…