当前位置: 首页 > news >正文

网站成立查询网络营销网站建设案例

网站成立查询,网络营销网站建设案例,做网站搜索结果的代码,icp备案查询官方网站搭建个场景: 将学生的信息,以顺序表的方式存储(堆区),并且实现封装函数︰1】顺序表的创建, 2】判满、 3】判空、 4】往顺序表里增加学生、5】遍历、 6】任意位置插入学生、7】任意位置删除学生、8】修改、 9】查找(按学生的学号查…

搭建个场景:
将学生的信息,以顺序表的方式存储(堆区),并且实现封装函数︰1】顺序表的创建,
2】判满、
3】判空、
4】往顺序表里增加学生、5】遍历、
6】任意位置插入学生、7】任意位置删除学生、8】修改、
9】查找(按学生的学号查找)、10】去重、
11】销毁顺序表
 

main.c

#include "head.h"
int main(int argc,const char *argv[])
{//创建学生的顺序表seqlist_ptr p=create_list();//判断顺序表是否为满int p1=full_doubt(p);//判断顺序表是否为空int p2=empty_doubt(p);//顺序表中添加学生数据add(p,6666);add(p,1001);add(p,1002);add(p,1003);add(p,1004);//顺序表中输出学生数据               output(p);//在任意位置插入学生insert(p,3,1111); output(p);//删除任意位置的学生del(p,3);output(p);//更改学生IDchange_index(p,3,6666);output(p);//查找学生IDfind(p,6666);//去重del_same(p);output(p);//释放my_free(p);return 0;
}

fun.c

  1 #include "head.h"                                                                                      2                                                                                                        3                                                                                                        4 //1.创建学生的顺序表                                                                                   5 seqlist_ptr create_list()                                                                              6 {                                                                                                      7     //申请堆区的空间                                                                                   8     seqlist_ptr p=(seqlist_ptr)malloc(sizeof(seqlist));                                                9     if(NULL==p)                                                                                        10     {                                                                                                  11         printf("顺序表创建失败\n");                                                                    12         return NULL;                                                                                   13     }                                                                                                  14                                                                                                        15     p->len=0;//将顺序表中的长度清零                                                                    16     //将数组的长度清零                                                                                 17     memset(p->ID,0,sizeof(p->ID));                                                                     18     printf("创建顺序表成功\n");                                                                        19     return p;                                                                                          20 }                                                                                                      21                                                                                                        22                                                                                                        23 //2.判断顺序表是否为满                                                                                 24 int full_doubt(seqlist_ptr p)                                                                          25 {                                                                                                      26     if(NULL==p)                                                                                        27     {                                                                                                  28         printf("顺序表不合法,无法判断");                                                               29         return -1;                                                                                     30     }                                                                                                  31     else if(p->len==MAX)                                                                               32     {                                                                                                  33         printf("顺序表满\n");                                                                          34         return 1;                                                                                      35     }                                                                                                  36                                                                                                        37     return 0;                                                                                          38 }                                                                                                      39                                                                                                        40                                                                                                        41 //3.判断顺序表是否为空                                                                                 42 int empty_doubt(seqlist_ptr p)                                                                         43 {                                                                                                      44     if(NULL==p)                                                                                        45     {                                                                                                  46         printf("顺序表不合法,无法判断");                                                               47     }                                                                                                  48     else if(p->len==0)                                                                                 49     {                                                                                                  50         printf("顺序表为空\n");                                                                        51         return 1;                                                                                      52     }                                                                                                  53     return 0;                                                                                          54 }                                                                                                      55                                                                                                        56                                                                                                        57 //4.顺序表数据的增加(添加学生的id号)                                                                   58 int add(seqlist_ptr p,datatype a)                                                                      59 {                                                                                                      60     if(NULL==p || full_doubt(p))                                                                       61     {                                                                                                  62         printf("无法增加\n");                                                                          63         return 0;                                                                                      64     }                                                                                                  65     p->ID[p->len]=a;                                                                                   66     p->len++;                                                                                          67     return 1;                                                                                          68 }                                                                                                      69                                                                                                        70                                                                                                        71 //5.顺序表中输出学生数据                                                                               72 int output(seqlist_ptr p)                                                                              73 {                                                                                                      74     if(NULL==p || empty_doubt(p))                                                                      75     {                                                                                                  76         printf("无法输出i\n");                                                                         77         return 0;                                                                                      78     }                                                                                                  79     for(int i=0;i<p->len;i++)                                                                          80     {                                                                                                  81         printf("%d    ",p->ID[i]);                                                                     82     }                                                                                                  83     printf("\n");                                                                                      84     return 1;                                                                                          85 }                                                                                                      86                                                                                                        87                                                                                                        88 //6.在任意位置插入学生数据                                                                             89 int insert(seqlist_ptr p,int index,datatype e)                                                         90 {                                                                                                      91     if(NULL==p || index>=MAX || index<=0 || empty_doubt(p))                                            92     {                                                                                                  93         printf("插入失败\n");                                                                          94         return -1;                                                                                     95     }                                                                                                  96     //此时的index表示数组的下标                                                                        97     index-=1;                                                                                          98     for(int i=0;i<p->len-index;i++)                                                                    99     {   //p->len表示未赋值的那个元素                                                                   
100         p->ID[p->len-i]=p->ID[p->len-1-i];                                                             
101     }                                                                                                  
102     //赋值                                                                                             
103     p->ID[index]=e;                                                                                    
104     //长度+1                                                                                           
105     p->len++;                                                                                          
106     return 1;                                                                                          
107 }                                                                                                      
108                                                                                                        
109                                                                                                        
110 //7.删除任意位置的学生                                                                                 
111 int del(seqlist_ptr p,int index)                                                                       
112 {                                                                                                      
113     if(NULL==p || index>MAX || index<=0 || empty_doubt(p))                                             
114     {                                                                                                  
115         printf("删除失败\n");                                                                          
116         return -1;                                                                                     
117     }                                                                                                  
118     //此时index表示数组的下标                                                                          
119     index-=1;                                                                                          
120     for(int i=index;i<p->len;i++)                                                                      
121     {                                                                                                  
122         p->ID[index]=p->ID[index+1];                                                                   
123     }                                                                                                  
124     p->len--;                                                                                          
125     return 1;                                                                                          
126 }                                                                                                      
127                                                                                                        
128                                                                                                        
129 //8.任意位置更改学生ID                                                                                 
130 int change_index(seqlist_ptr p,int index,datatype e)                                                   
131 {                                                                                                      
132     if(NULL==p || index>MAX || index <=0 || empty_doubt(p))                                            
133     {                                                                                                  
134         printf("更改失败\n");                                                                          
135         return -1;                                                                                     
136     }                                                                                                  
137     index-=1;                                                                                          
138     p->ID[index]=e;                                                                                    
139     return 1;                                                                                          
140 }                                                                                                      
141                                                                                                        
142                                                                                                        
143 //9.查找学生ID                                                                                         
144 int find(seqlist_ptr p,datatype e)                                                                     
145 {                                                                                                      
146     if(NULL==p || empty_doubt(p))                                                                      
147     {                                                                                                  
148         printf("查找失败\n");                                                                          
149         return -1;                                                                                     
150     }                                                                                                  
151     int flag=0;                                                                                        
152     for(int i=0;i<p->len;i++)                                                                          
153     {                                                                                                  
154         if(p->ID[i]==e)                                                                                
155         {                                                                                              
156             flag=1;                                                                                    
157             printf("查找的学生是第%d位学生\n",i+1);                                                    
158             return i;                                                                                  
159         }                                                                                              
160                                                                                                        
161         if(flag=0)                                                                                     
162         {                                                                                              
163             printf("未查找到学生ID\n");                                                                
164             return 0;                                                                                  
165         }                                                                                              
166     }                                                                                                  
167 }                                                                                                      
168                                                                                                        
169                                                                                                        
170 //10.去重                                                                                              
171 int del_same(seqlist_ptr p)                                                                            
172 {                                                                                                      
173     if(NULL==p || empty_doubt(p))                                                                      
174     {                                                                                                  
175         printf("去重失败\n");                                                                          
176         return -1;                                                                                     
177     }                                                                                                  
178     for(int i=0;i<p->len;i++)                                                                          
179     {                                                                                                  
180         for(int j=i+1;j<p->len;j++)                                                                    
181         {                                                                                              
182             if(p->ID[i]==p->ID[j])                                                                     
183             {                                                                                          
184                 del(p,j+1);                                                                            
185                 j--;                                                                                   
186             }                                                                                          
187         }                                                                                              
188     }                                                                                                  
189     return 1;                                                                                          
190 }                                                                                                      
191                                                                                                        
192                                                                                                        
193 //11 释放                                                                                              
194 int my_free(seqlist_ptr p)                                                                             
195 {                                                                                                      
196     if(NULL==p)                                                                                        
197     {                                                                                                  
198         printf("释放失败\n");                                                                          
199         return -1;                                                                                     
200     }                                                                                                  
201     free(p);                                                                                           
202         printf("释放成功\n");                                                                          
203     return 1;                                                                                          
204                                                                                                        
205 }                                                                                                      
~                                                                                                          

head.h

#ifndef __HEAD_H__                                   
#define __HEAD_H__                                   
#include <stdio.h>                                   
#include <stdlib.h>                                  
#include <string.h>                                  
//顺序标容器存储学生个数的最大值                     
#define MAX 30                                       
//宏替换ID的数据类型                                 
typedef int datatype;                                
//创建顺序表用于存储学生的信息                       
typedef struct sequence                              
{                                                    datatype ID[MAX];                                //存储学生的个数                                 int len;                                         
}seqlist,*seqlist_ptr;                               //1.创建学生的顺序表                                 
seqlist_ptr create_list();                           
//2.判断顺序表是否为满                               
int full_doubt(seqlist_ptr p);                       
//3.判断顺序表是否为空                               
int empty_doubt(seqlist_ptr p);                      
//4.顺序表数据的增加(添加学生的id号)                 
int add(seqlist_ptr p,datatype a);                   
//5.顺序表中输出学生数据                             
int output(seqlist_ptr p);                           
//6.在任意位置插入学生数据                           
int insert(seqlist_ptr p,int index,datatype e);      
//7.删除任意位置的学生                               
int del(seqlist_ptr p,int index);                    
//8.任意位置更改学生ID                               
int change_index(seqlist_ptr p,int index,datatype e);
//9.查找学生ID                                       
int find(seqlist_ptr p,datatype e);                  
//10.去重                                            
int del_same(seqlist_ptr p);                         
//11 释放                                            
int my_free(seqlist_ptr p);                          
#endif                                               

 

http://www.hkea.cn/news/738306/

相关文章:

  • winforms做网站注册百度账号
  • 玉泉路网站建设营销培训课程有哪些
  • 渭南做网站费用搜索引擎排名优化是什么意思
  • 做网站开发需要学什么软件微信公众平台开发
  • 网站整体营销方案网络营销的特点是什么?
  • 国内知名的网站建设公司有哪些百度指数专业版app
  • 画画外包网站如何推广一个网站
  • 互联网公司响应式网站深圳google推广
  • 深圳网站设计哪好什么推广平台比较好
  • 打开英文网站字体不对教程seo推广排名网站
  • 昭通市建设局网站太原百度关键词优化
  • 个人建网站允许吗seo职位要求
  • 环保网站设计网络营销优化推广
  • 网页设计网站制作公司冯耀宗seo视频教程
  • 怎么用路由器做网站百度指数平台官网
  • 济南做网站互联网公司有哪些seo是什么公司
  • 辛集seo网站优化价格许昌网站seo
  • 网站建设后期维护百度快速收录技术
  • 网站建设中的推广工作seo学校培训
  • 上海专业网站建设网百度搜索推广开户
  • 做学校网站素材图片合肥seo代理商
  • 真题真做报名网站淘宝搜索关键词排名
  • 免费的黄冈网站有哪些平台?培训行业seo整站优化
  • 寿县住房与城乡建设局网站真正免费的网站建站平台
  • 常德seo招聘网站seo站长工具
  • 网站开发多久完成俄罗斯搜索引擎yandex推广入口
  • 漳州做网站建设建网站免费
  • 网站建设服务上海广州软文推广公司
  • 做一个网站app需要多少钱web制作网站的模板
  • 网站建设的财务计划新媒体营销策略有哪些