日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数据结构实验六 综合数据处理

發布時間:2023/12/10 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数据结构实验六 综合数据处理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

廣州大學學生實驗報告

?

開課實驗室:計算機科學與工程實驗(電子樓416A) ????2019年6月14日

學院

計算機科學與教育軟件學院

年級、專業、班

計算機大類

144班

姓名

?

學號

?

實驗課程名稱

數據結構實驗

成績

?

實驗項目名稱

實驗六 數據處理綜合實驗

指導老師

?

一、實驗目的

掌握線性的定義及基本操作,用鏈表實現:遍歷、查找、插入、刪除、翻轉。

二、使用儀器、器材

微機一臺

操作系統:WinXP

編程軟件:C++

三、實驗內容及原理

實驗內容:

  • 設計問卷調查表內容:
  • 必填:身份(自己設計分類,例如:學生/體力勞動者/腦力勞動者)

    年齡

    性別

    選填:自行設計單項選擇題、填空題

    例如:可接受的價格范圍(自己設計,可以上限/下限,或某個值+上下浮動)

    屏幕大小/整機大小

    重量

    顏色(也可以選擇忽略,即不介意)

    待機時間

    拍照質量

    音響效果

    對以上各項指標重要程度的排序

    ……

  • 有50人填寫了問卷,某些問題必答、某些問題允許不答
  • 自行設計數據輸入方法(例如讀.txt或.xls文件)
  • 數據處理功能:自行基于問題的數據處理,例如

  • 不同群體最喜歡的手機品牌
  • 不同年齡段最喜歡的手機品牌
  • 學生群體中接受各個價格區間的比例
  • 最受歡迎的手機屏幕尺寸
  • 男性和女性各自最喜歡的手機顏色
  • 接受2000-2999價格區間的上班族最希望的手機拍照效果
  • 最受退休人員歡迎的手機續航
  • ?

    • 實驗過程原始數據記錄

    ?

    // ConsoleApplication76.cpp : 定義控制臺應用程序的入口點。

    //

    ?

    #include "stdafx.h"

    ?

    #include <iostream>

    #include <fstream>

    #include"manage.h"

    using namespace std;

    ?

    int main()

    {

    ??? LinkNode *person;

    ??? Createlink(person);

    ??? ageR(person);

    ??? identityR(person);

    ??? brandR(person);

    ??? sex_graph(person);

    }

    ?

    ?

    #pragma once

    // 單鏈表基本運算算法

    #include <stdio.h>

    #include <malloc.h>

    typedef int ElemType;

    #define MAXL 100????? //最大長度

    typedef int KeyType;? //定義關鍵字類型為int

    typedef char InfoType;

    typedef struct LNode

    {

    ??? int identity; //身份? 0表示學生 1表示上班族? 2表示退休人員 3表示其他

    ??? int age;? //年齡段 0表示20歲以下 1表示21-50歲 2表示51歲以上

    ??? int sex; //性別?? 0表示男? 1表示女

    ?

    ??? int brand; //手機的品牌? 0表示OPPO 1表示vivo 2表示華為 3表示榮耀 4表示蘋果 5表示小米

    ??? int price; //手機的價格區間 0表示1000以下 1表示1000-1999 2表示2000-2999 3表示3000以上

    ??? int size; // 手機屏幕的尺寸 0表示4.5英寸 1表示5.5英寸 2表示6英寸以上

    ??? int color; //手機的顏色 0表示黑 1表示白 2表示藍 3表示其他

    ??? int graph; //0表示不介意 1表示基本清晰就可以 2表示拍照效果要好

    ??? int battery; //0表示續航久 1表示無所謂

    ?

    ??? struct LNode *next;?????? //指向后繼結點

    } LinkNode;??????????????????? //聲明單鏈表結點類型

    ?

    typedef struct

    {

    ??? KeyType key;????? //關鍵字項

    ??? char* data;?????? //其他數據項,類型為InfoType

    } RecType;??????????????? //查找元素的類型

    ?

    ?

    void CreateListF(LinkNode *&L, ElemType id[], ElemType a[], ElemType sa[], ElemType b[], ElemType p[], ElemType si[], ElemType c[],

    ??? ElemType g[], ElemType ba[], int n);

    ?

    //尾插法建立單鏈表

    ?

    void InitList(LinkNode *&L);

    ?

    void DestroyList(LinkNode *&L);

    ?

    ?

    void DispList(LinkNode *L);

    ?

    bool GetElem(LinkNode *L, int i, ElemType &e);

    ?

    ?

    void Createlink(LinkNode *&L);

    ?

    void BubbleSort(RecType R[], int n);//冒泡排序

    ?

    void CreateList(RecType R[], KeyType keys[], int n); //創建順序表

    void CreateListage(RecType R[], KeyType keys[], int n);? //創建順序表

    void Createbrand(RecType R[], KeyType keys[], int n); //創建順序表

    void Creategraph(RecType R[], KeyType keys[], int n); //創建順序表

    void Createidentity(RecType R[], KeyType keys[], int n); //創建順序表

    void DispList(RecType R[], int n); //輸出順序表

    ?

    void ageR(LinkNode *L);

    void identityR(LinkNode *L);

    void brandR(LinkNode *L);

    void sex_graph(LinkNode * L);

    ?

    ?

    ?

    // 單鏈表基本運算算法

    #include "stdafx.h"

    #include"manage.h"

    #include"iostream"

    using namespace std;

    void CreateListF(LinkNode *&L,? ElemType id[], ElemType a[], ElemType sa[], ElemType b[], ElemType p[], ElemType si[], ElemType c[],

    ??? ElemType g[], ElemType ba[], int n)

    //頭插法建立單鏈表

    {

    ??? LinkNode *s;

    ??? L = (LinkNode *)malloc(sizeof(LinkNode));? //創建頭結點

    ??? L->next = NULL;

    ??? for (int i = 0; i<n; i++)

    ??? {

    ???????? s = (LinkNode *)malloc(sizeof(LinkNode));//創建新結點s

    ???????? s->identity = id[i];

    ???????? s->age = a[i];

    ???????? s->sex = sa[i];

    ???????? s->brand = b[i];

    ???????? s->price = p[i];

    ???????? s->size = si[i];

    ???????? s->color = c[i];

    ???????? s->graph = g[i];

    ???????? s->battery = ba[i];

    ???????? s->next = L->next;???????????? //將結點s插在原開始結點之前,頭結點之后

    ???????? L->next = s;

    ??? }

    }

    ?

    void InitList(LinkNode *&L)

    {

    ??? L = (LinkNode *)malloc(sizeof(LinkNode));? //創建頭結點

    ??? L->next = NULL;

    }

    void DestroyList(LinkNode *&L)

    {

    ??? LinkNode *pre = L, *p = pre->next;

    ??? while (p != NULL)

    ??? {

    ???????? free(pre);

    ???????? pre = p;

    ???????? p = pre->next;

    ??? }

    ??? free(pre);?? //此時p為NULL,pre指向尾結點,釋放它

    }

    void DispList(LinkNode *L)

    {

    ??? LinkNode *p = L->next;

    ??? while (p != NULL)

    ??? {

    ???????? printf("%d ", p->identity);

    ???????? p = p->next;

    ??? }

    ??? printf("\n");

    }

    void ageR(LinkNode *L)

    {

    ??? int age[3];

    ??? age[0] = 0;

    ??? age[1] = 0;

    ??? age[2] = 0;

    ??? LinkNode *p = L->next;

    ??? while (p != NULL)

    ??? {

    ???????? if (p->age == 0)age[0]++;

    ???????? else if (p->age == 1)age[1]++;

    ???????? else if (p->age == 2)age[2]++;

    ???????? p = p->next;

    ??? }

    ??? printf("年齡在20歲以下的有%d人\n", age[0]);

    ??? printf("年齡在21-50歲的有%d人\n", age[1]);

    ??? printf("年齡在51歲以下的有%d人\n", age[2]);

    ??? RecType R[3];

    ??? CreateListage(R, age,3);? //創建順序表

    ??? BubbleSort(R, 3);

    ??? printf("最多人處在年齡階段為:%s \n", R[0].data);

    }

    bool GetElem(LinkNode *L, int i, ElemType &e)

    {

    ??? int j = 0;

    ??? LinkNode *p = L;

    ??? if (i <= 0) return false;????? //i錯誤返回假

    ??? while (j<i && p != NULL)

    ??? {

    ???????? j++;

    ???????? p = p->next;

    ??? }

    ??? if (p == NULL)???????????????? //不存在第i個數據結點

    ???????? return false;

    ??? else????????????????????? //存在第i個數據結點

    ??? {

    ???????? //e = p->data;

    ???????? return true;

    ??? }

    }

    ?

    void Createlink(LinkNode *& L)

    {

    ??? FILE *stream1;

    ??? freopen_s(&stream1,"C:\\test.txt", "r", stdin);? //從文件中讀取隨機生成的調查對象

    ??? int num = 0;

    ??? L = new LinkNode;

    ??? L->next = NULL;

    ??? LinkNode* p = new LinkNode;

    ??? while (cin >> p->identity) {

    ???????? num++;?? //統計本次調查對象的人數

    ???????? cin >> p->age >> p->sex >> p->brand

    ???????????? >> p->price >> p->size >> p->color

    ???????????? >> p->graph >> p->battery;

    ???????? p->next = L->next;

    ???????? L->next = p;

    ???????? p = new LinkNode;

    ??? }

    ??? delete p;

    ?

    ??? cout << "本次參與調查對象的人數有:" << num << "\n\n";

    }

    //冒泡排序算法

    ?

    void BubbleSort(RecType R[], int n)

    {

    ??? int i, j, k;

    ??? RecType tmp;

    ??? for (i = 0; i < n - 1; i++)

    ??? {

    ???????? for (j = n - 1; j > i; j--)??? //比較,找出本趟最小關鍵字的記錄

    ???????????? if (R[j].key < R[j - 1].key)

    ???????????? {

    ????????????????? tmp = R[j];? //R[j]與R[j-1]進行交換,將最小關鍵字記錄前移

    ????????????????? R[j] = R[j - 1];

    ????????????????? R[j - 1] = tmp;

    ???????????? }

    ??? }

    }

    void CreateList(RecType R[], KeyType keys[], int n)

    {

    ??? for (int i = 0; i < n; i++)???????????? //R[0..n-1]存放排序記錄

    ???????? R[i].key = keys[i];

    }

    void CreateListage(RecType R[], KeyType keys[], int n)?? //創建順序表

    {

    ??? for (int i = 0; i < n; i++)???????????? //R[0..n-1]存放排序記錄

    ??? {

    ???????? R[i].key = keys[i];

    ??? }

    ??? R[0].data = "20歲以下";

    ??? R[1].data = "20歲-51歲";

    ??? R[2].data = "51歲以上";

    }

    void Createbrand(RecType R[], KeyType keys[], int n)

    {

    ??? for (int i = 0; i < n; i++)???????????? //R[0..n-1]存放排序記錄

    ??? {

    ???????? R[i].key = keys[i];

    ??? }

    ??? R[0].data = "OPPO";

    ??? R[1].data = "vivo";

    ??? R[2].data = "華為";

    ??? R[3].data = "榮耀";

    ??? R[4].data = "蘋果";

    ??? R[5].data = "小米";

    ?

    }

    void Creategraph(RecType R[], KeyType keys[], int n)

    {

    ??? for (int i = 0; i < n; i++)???????????? //R[0..n-1]存放排序記錄

    ??? {

    ???????? R[i].key = keys[i];

    ??? }

    ??? R[0].data = "表示不介意";

    ??? R[1].data = "表示基本清晰就可以";

    ??? R[2].data = "表示拍照效果要好";

    }

    void Createidentity(RecType R[], KeyType keys[], int n)? //創建順序表

    {

    ??? for (int i = 0; i < n; i++)???????????? //R[0..n-1]存放排序記錄

    ??? {

    ???????? R[i].key = keys[i];

    ??? }

    ??? R[0].data = "學生";

    ??? R[1].data = "上班族";

    ??? R[2].data = "其他";

    }

    void DispList(RecType R[], int n)? //輸出順序表

    {

    ??? for (int i = 0; i < n; i++)

    ???????? printf("%d ", R[i].key);

    ??? printf("\n");

    }

    ?

    void identityR(LinkNode *L)

    {

    ??? int identity[3];

    ??? identity[0] = 0;

    ??? identity[1] = 0;

    ??? identity[2] = 0;

    ??? LinkNode *p = L->next;

    ??? while (p != NULL)

    ??? {

    ???????? if (p->identity == 0)identity[0]++;

    ??? ??? else if (p->identity == 1)identity[1]++;

    ???????? else if (p->identity == 2)identity[2]++;

    ???????? p = p->next;

    ??? }

    ??? printf("身份是學生的有%d人\n", identity[0]);

    ??? printf("身份是上班族的有%d人\n", identity[1]);

    ??? printf("身份為其他的有%d人\n", identity[2]);

    ??? RecType R[3];

    ??? Createidentity(R, identity, 3);??? //創建順序表

    ??? BubbleSort(R, 3);

    ??? printf("填選問卷身份最多的是:%s \n", R[0].data);

    }

    ?

    void brandR(LinkNode * L)

    {

    ??? int brand[6];

    ??? brand[0] = 0;

    ??? brand[1] = 0;

    ??? brand[2] = 0;

    ??? brand[3] = 0;

    ??? brand[4] = 0;

    ??? brand[5] = 0;

    ??? LinkNode *p = L->next;

    ??? while (p != NULL)

    ??? {

    ???????? if (p->brand == 0)brand[0]++;

    ???????? else if (p->brand == 1)brand[1]++;

    ???????? else if (p->brand == 2)brand[2]++;

    ???????? else if (p->brand == 3)brand[3]++;

    ???????? else if (p->brand == 4)brand[4]++;

    ???????? else if (p->brand == 5)brand[5]++;

    ???????? p = p->next;

    ??? }

    ??? printf("喜歡OPPO的有%d人\n", brand[0]);

    ??? printf("喜歡vivo的有%d人\n", brand[1]);

    ??? printf("喜歡華為的有%d人\n", brand[2]);

    ??? printf("喜歡榮耀的有%d人\n", brand[3]);

    ??? printf("喜歡蘋果的有%d人\n", brand[4]);

    ??? printf("喜歡小米的有%d人\n", brand[5]);

    ??? RecType R[6];

    ??? Createbrand(R, brand, 6);? //創建順序表

    ??? BubbleSort(R, 6);

    ??? printf("最受歡迎的品牌是:%s \n", R[5].data);

    }

    ?

    void sex_graph(LinkNode * L)//0表示不介意 1表示基本清晰就可以 2表示拍照效果要好

    {

    ??? int graphman[3];

    ??? int graphfemale[3];

    ??? graphman[0] = 0;

    ??? graphman[1] = 0;

    ??? graphman[2] = 0;

    ??? graphfemale[0] = 0;

    ??? graphfemale[1] = 0;

    ??? graphfemale[2] = 0;

    ??? LinkNode *p = L->next;

    ??? while (p != NULL)

    ??? {

    ???????? if (p->sex == 0&&p->graph==0)

    ???????????? graphman[0]++;

    ???????? else if (p->sex == 0 && p->graph == 1)graphman[1]++;

    ???????? else if (p->sex == 0 && p->graph == 2)graphman[2]++;

    ???????? else if (p->sex == 1 && p->graph == 0)graphfemale[0]++;

    ???????? else if (p->sex == 1 && p->graph == 1)graphfemale[1]++;

    ???????? else if (p->sex == 1 && p->graph == 2)graphfemale[2]++;

    ????????

    ???????? p = p->next;

    ??? }

    ?

    ??? RecType R1[3];

    ??? RecType R2[3];

    ??? Creategraph(R1, graphman, 3);? //創建順序表

    ??? Creategraph(R2, graphfemale, 3);?? //創建順序表

    ??? BubbleSort(R1, 3);

    ??? BubbleSort(R1, 3);

    ??? printf("男性對手機相機的態度更注重于:%s \n", R2[0].data);

    ??? printf("女性對手機相機的態度更注重于:%s \n", R1[0].data);

    }

    ?

    ?

    五、實驗結果及分析

    ?

    問卷鏈接:https://www.wjx.cn/jq/40339278.aspx

    問卷截圖

    ???

    實驗中使用鏈表存儲結構,使用了冒泡排序。對數據處理有些采用了關聯數據處理,例如把性別和對相機注重數據聯合在一起分析。由于電腦損壞,重新寫了一次,因此對某些數據做了簡單分析。

    ?

    ?

    ?

    ?

    總結

    以上是生活随笔為你收集整理的数据结构实验六 综合数据处理的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。