當前位置:首頁 » 編程語言 » 數據結構c語言版程序
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

數據結構c語言版程序

發布時間: 2022-03-16 03:24:00

Ⅰ 數據結構(c語言版) 程序題

兄弟,問下你學的數據結構的書是什麼作者的?有代碼嗎?適合初學者嗎?

Ⅱ 求數據結構(C語言版)程序

用結構體做要好的多
時間關系簡單寫了下
你自己可以用結構體
做下一個建立一個刪
除函數main函數一調
用完事,也節約內存
#include<stdio.h>
void main()
{
int n,i,p,q;int a[50];
printf("輸入數據\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf("輸入插入數據和位置\n");
scanf("%d,%d",&p,&q);
for(i=n+1;i>q;i--)
a[i]=a[i-1];
a[q]=p;
for(i=1;i<=n+1;i++)
printf("%-2d",a[i]);
}

Ⅲ 編寫 數據結構(C語言版)的軟體叫什麼。

數據結構(c語言版)裡面的那些程序可以用VC 6.0來實現。其它C語言的編譯器也可以

Ⅳ 數據結構C語言源程序

string s="jyguhttyyt";
string t="sadfwefwafwwafehrrtfdghr";
string r;
size_t i=0;
i=s.find_first_not_of(t);
while(i!=s.length()&&i!=string::npos)
{
size_t j=r.find_first_of(s[i]);
if(j==string::npos)
{
r+=string(s,i,1);
}
i=s.find_first_not_of(t,i+1);
}
cout<<r<<endl;

Ⅳ 數據結構c語言版程序設計

#include<stdio.h>
#include<string.h>
#defineMAXLEN1000
intmain()
{
unsignedlongresult=0;
intmax=1;
intcount=0;
intmin=999999;
doubleavg;

intinput;
while(1)
{
if(scanf("%d",&input))
{
if(input<0)
{
break;
}
max=max>input?max:input;
min=min<input?min:input;
result+=input;
count++;
}
else
{
//輸入錯誤處理
}
}

avg=result*1.0/count;
printf(" 一共輸入:%d 和:%d 最大值:%d 最小值:%d 平均值:%f ",count,result,max,min,avg);
}

Ⅵ 幫忙設計個程序,數據結構C語言版的。

/*
將沒有頭結點的鏈表中的字元數據分類
用三個帶頭結點的鏈表存放
*/
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *next;
}node,*list;
//輸入原始字元串進無頭結點的鏈表
list input(){
char ch;
char e;
list L=NULL,p,q;
printf("\n請輸入數據(空格隔開):\n");
do{
scanf("%c",&e);
ch=getchar();
if(L==NULL){
p=(list)malloc(sizeof(node));
if(!p){
printf("\n分配空間失敗\n");
exit(1);
}
p->data=e;
L=p;
}
else{
q=(list)malloc(sizeof(node));
if(!q){
printf("\n分配空間失敗\n");
exit(1);
}
q->data=e;
q->next=NULL;
p->next=q;
p=q;
}
}while(ch!='\n');
return L;
}
//初始化帶頭結點的鏈表
list init(){
list L;
L=(list)malloc(sizeof(node));
if(!L){
printf("\n分配空間失敗\n");
exit(1);
}
L->next=NULL;
return L;
}
//輸出鏈表中的數據
void output(list L,int i){ //i判斷鏈表類型
list p;
switch(i){ //無頭結點
case 0:
p=L;
break;
case 1:
p=L->next; //有頭結點
break;
}
do{
printf("%c",p->data);
p=p->next;
}while((p!=L&&i==1)||(p->next&&i==0));
printf("\n");
}
//把元素插到鏈表末端
void insert(list L,char e){
list p=L,q;
while(p->next){ //使p指向最後
p=p->next;
}
q=(list)malloc(sizeof(node));
if(!q){
printf("\n分配空間失敗\n");
exit(1);
}
q->data=e;
q->next=NULL;
p->next=q;
p=q;
}
void circle(list L){
list p=L;
while(p->next){
p=p->next;
}
p->next=L;
}
void main(){
list L,L1,L2,L3;
list p;
L=input(); //存英文
L1=init(); //存數字
L2=init(); //存其他符號
L3=init();
p=L;
while(p){
if(p->data>='a'&&p->data<='z'||p->data>='A'&&p->data<='Z'){
insert(L1,p->data);
p=p->next;
}
else if(p->data>='0'&&p->data<='9'){
insert(L2,p->data);
p=p->next;
}
else{
insert(L3,p->data);
p=p->next;
}
}
circle(L1);
circle(L2);
circle(L3);
printf("\n原始數據:");
output(L,0);
printf("\n英文字元:");
output(L1,1);
printf("\n數字:");
output(L2,1);
printf("\n其他字元:");
output(L3,1);
}

Ⅶ 數據結構 c語言版 程序填充

#include <stdio.h>

#define MAXSIZE 100
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0

// 學生信息
typedef struct {
char num[8]; // 學號
char name[9]; // 姓名
char gender[3];// 性別
int score; // 成績
} STU;

// 鏈表結構
typedef struct node {
STU data;
struct node *next;
} ListNode,*LinkList;

// 棧結構
typedef struct
{
STU stack[MAXSIZE];
int top;
}SqStack;

// 創建鏈表
LinkList CreateList(int n)
{
int i;
LinkList head,p,q;

for(i=1;i<=n;i++)
{
p=(LinkList)malloc(sizeof(ListNode));
scanf("%s%s%s%d",p->data.num,p->data.name,\
p->data.gender,&p->data.score);
if(i==1) head=q=p;
else
{
q->next=p;
q=p;
}
}
q->next=NULL; // 表尾

return head;
}

// 輸出鏈表
void PrintList(LinkList head)
{
LinkList p=head;

while(p)
{
printf("%s %s %s %d\n",p->data.num,p->data.name,\
p->data.gender,p->data.score);
p=p->next;
}
}

// 初始化棧
SqStack *InitStack(void)
{
SqStack *st=(SqStack*)malloc(sizeof(SqStack));
st->top=MAXSIZE;

return st;
}

// 壓棧
int push(SqStack *st,STU stu)
{
if(st->top)
{
st->stack[--st->top]=stu;
return OK;
}
else return ERROR;
}

// 棧空
int StackEmpty(SqStack *st)
{
if(st->top==MAXSIZE)
return TRUE;
else return FALSE;
}

// 出棧
STU *pop(SqStack *st)
{

return &st->stack[st->top++];
}

// 逆置鏈表
void RevLinkList(LinkList head)
{
LinkList p=head;
SqStack *st=InitStack();

while(p)
{
push(st,p->data);
p=p->next;
}

p=head;
while(!StackEmpty(st))
{
p->data=*pop(st);
p=p->next;
}
}

int main(void)
{
int n;
LinkList head; // 表頭

printf("輸入學生個數: ");
scanf("%d",&n);
printf("請輸入學生信息:\n");
head=CreateList(n);
printf("輸入的學生信息如下:\n");
PrintList(head);

RevLinkList(head);
printf("逆置後學生信息:\n");
PrintList(head);

return 0;
}

稍微有些改動,對比看下。。。。

Ⅷ 求數據結構(c語言版)程序源代碼

1 #include <string.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #define MAX_POS_NUM 100
6 #define MAX_STR_LEN 1024
7
8
9 //1. get all position of str_z in str_x
10 int get_sub_str_pos(const char * str_x, const char * str_z, int sub_str_pos[])
11 {
12 if (NULL == str_x || NULL == str_z)
13 {
14 printf("in error!\n");
15 return -1;
16 }
17
18 const char * pos_ptr = NULL;
19
20 pos_ptr = strstr(str_x,str_z);
21
22 int i=0;
23 while(pos_ptr)
24 {
25 printf("substring positon:%d\n",pos_ptr-str_x+1);
26 sub_str_pos[i] = pos_ptr - str_x + 1;
27 pos_ptr = strstr(pos_ptr+strlen(str_z),str_z);
28 i++;
29 }
30
31 return 0;
32 }
33
34 //2. get max length common string of str_x and str_y
35 char * get_max_com_str(const char * str_x, const char * str_y)
36 {

37 int x_len = strlen(str_x);
38 int y_len = strlen(str_y);
39
40 char * tmp_str = new char[y_len+1];
41
42 for(int i=y_len; i>0; i--) // i is substring length
43 {
44 if (i>x_len)
45 continue;
46 for(int j=0;j<=y_len-i; j++) // j is substring start postion
47 {
48 snprintf(tmp_str,i+1,"%s",str_y);
49 if (strstr(str_x,tmp_str))
50 {
51 printf("%s\n",tmp_str);
52 printf("max common substring length:%d\n",i);
53 return tmp_str;
54 }
55 }
56 }
57
58 return NULL;
59 }
60
61 //3. replace all substring in question 1
62 char * replace_sub_str(const char * str_x, char * max_com_str, int sub_str_pos[], int sub_str_len)
63 {
64 char * replaced_str = new char[MAX_STR_LEN];
65
66 int sub_pos = sub_str_pos[0];
67 int l=0; // l is sub_str_pos index
68 int i=0,j=0; //i is str_x pos, j is replaced_str pos
69
70 while(*str_x)

71 {
72 if (i==sub_pos-1) // replace from this position
73 {
74 // printf ("i:%d,\n",i);
75 for (int k=0; k<strlen(max_com_str); k++)
76 {
77 *(replaced_str + j) = * (max_com_str + k);
78 j++;
79 }
80 i += sub_str_len;
81 str_x += sub_str_len;
82 l++;
83 sub_pos = sub_str_pos[l];
84 continue;
85 }
86 *(replaced_str+j) = *str_x++;
87 i++;
88 j++;
89 }
90
91 * (replaced_str + j) = '\0';
92
93 return replaced_str;
94 }
95
96 int main()
97 {
98 const char * str_x = "abcabcabc";
99 const char * str_y = "cabcd";
100 const char * str_z = "abc";
101
102 int sub_str_pos [MAX_POS_NUM] = {0};
103
104 char * max_com_str = NULL;

105
106 char * replaced_str = NULL;
107
108 get_sub_str_pos(str_x,str_z,sub_str_pos);
109 max_com_str = get_max_com_str(str_x,str_y);
110
111 printf("max common str: %s\n",max_com_str);
112
113 replaced_str = replace_sub_str(str_x, max_com_str, sub_str_pos, strlen(str_z));
114 printf("repalced str: %s\n",replaced_str);
115
116 return 0;
117 }

Ⅸ 數據結構(C語言版)編程題

倒 題目是靠自己想的,如果你基礎不好,拿別人的又有什麼意思呢

Ⅹ 數據結構(c語言版)裡面的那些程序是用什麼工具實現的。。

數據結構(c語言版)裡面的那些程序可以用VC 6.0來實現。其它C語言的編譯器也可以。
ASP.net 要用來做網路編程的,要一些網路知識和一點編程的基礎。
ASP的前景不如PHP和JSP,ASP不要花太多的時間去學了。