《高级语言程序设计》实验报告


    

    高级语言程序设计
    课 程 实 验 报 告


    专 业: 软件工程
    年 级: 17级
    姓 名: **
    学 号: 201742060220
    教 师: ***
    日 期: 2018101


    ** 民 族 学
    目录
    实验目 3
    二 务求 3
    三 标识符数结构 4
    四 问题分析算法设计 6
    五 程序运行测试实例 11
    六 问题总结 15
    附录(源代码) 15


    实验目
    1 掌握新学线性表操作
    2 加深书写代码流畅度
    二 务求
    1 问题描述
    l 题目1:设计种单链表存储项式结构(结点存储项系数指数类型int)编写产生项式链表函数实现两项式相加相函数
    l 题目2:试章介绍两种josephus问题求解程计算机中实现实现时求输出整数实际名
    l 题目3:
    2 设计达求
    l 正确输出题目求结果
    l 正确线性表
    三 标识符数结构
    说明:1描述清楚标识符 格式

    标识符
    数类型
    含义
    第题
    ptrNode
    struct node

    typedef 转换
    Coefficient Exponent


    int
    指数系数
    headrp

    LinkList
    生成结点遍历链表函数(LinkList creatList(int n))
    ha hb
    Position
    函数LinkList add_List(LinkList a LinkList b)完成项式相加操作
    crp
    LinkList
    函数LinkList add_List(LinkList a LinkList b)完成项式相加操作
    ha hb
    Position
    函数LinkList mul_List(LinkList a LinkList b)完成项式相
    ctempCrp
    LinkList
    函数LinkList mul_List(LinkList a LinkList b)完成项式相
    hc
    LinkList
    函数void printList(LinkList L)遍历链表进行输出链表操作
    n1n2
    int
    函数中需输入项式项数
    L1L2L3L4
    LinkList
    函数中接受调函数返回值
    第二题
    标识符
    数类型
    含义

    DataType

    struct Person
    结构体数类型
    typedef struct Node* PNode

    LinkList
    struct Node
    结构体数类型
    typedef struct Node* LinkList

    PLinkList
    LinkList
    typedef LinkList* PLinkList

    pq
    PNode
    PNode类型指针函数int init_clist(PLinkList pclist int n)

    p pre
    PNode
    PNode类型指针函数void josephus_clist(PLinkList pclist int s int m)

    xyz
    int
    循环表总数x第y开始数第z 出局

    josephus
    LinkList
    LinkList类型指针函数中
    第三题
    标识符
    数类型
    含义

    Plist
    Data
    struct List
    结构体数类型

    numbername
    Char
    存放电话号存放姓名

    next
    struct List
    struct List指针变量

    Plist
    data
    delpt
    pList
    中间变量

    count
    int
    作计算数

    四 问题分析算法设计
    1 问题分析
    说明:分析程序题目求详细说明程序设计思想
    2 算法设计
    l 第题
    S1:定义struct node{
    ElementType Coefficient
    ElementType Exponent
    Position next
    }
    S2:typedef struct node *ptrNode
    typedef ptrNode LinkList 头结点
    typedef ptrNode Position中间节点
    typedef int ElementType
    S3:写函数int IsEmpty(LinkList L)判断参数LinkList L空
    S4: 写函数LinkList add_List(LinkList a LinkList b)进行项式加法计算
    S5:写函数LinkList mul_List(LinkList a LinkList b)进行项式法计算
    S6: 函数中调函数输出加法结果法结果
    处出进行加法LinkList add_List(LinkList a LinkList b)函数算法:
    S1:函数形参LinkList a LinkList b定义Position ha hbLinkList crp int temp
    S2:ha a>next hb b>next
    S3:分配存储空间C然r c
    S4:然循坏while((ha NULL)&&(hb NULL))分配存储空间p
    S5:if(ha>Exponent < hb>Exponent)条件p>Exponent hb>Exponent p>Coefficient hb>Coefficient hb hb>next r>next p r p
    S6:else if(ha>Exponent > hb>Exponent) 条件p>Exponent ha>Exponent p>Coefficient ha>Coefficient ha ha>next r p
    S7:else 条件{
    temp ha>Coefficient + hb>Coefficient
    if(temp 0){
    p>Exponent ha>Exponent
    p>Coefficient temp
    r>next p
    r p }
    hb hb>next
    ha ha>next } }
    S8:操作完成if(hb NULL)进行while(ha NULL){
    p (struct node*)malloc(sizeof(struct node))
    p>Exponent ha>Exponent
    p>Coefficient ha>Coefficient
    ha ha>next
    r>next p
    r p
    }
    S9:if(hb NULL)进行while(ha NULL){
    p (struct node*)malloc(sizeof(struct node))
    p>Exponent ha>Exponent
    p>Coefficient ha>Coefficient
    ha ha>next
    r>next p
    r p
    }
    S10:r>next NULL
    S11:返回值return c
    l 第二题
    S1: 定义struct Person结构体{ int num char name[8] } typedef struct Person DataType词结构体存储 元素
    S2:创建struct Nodetypedef struct Node* PNode结点类型
    S3:struct Node{ DataType info PNode link } typedef struct Node* LinkListtypedef LinkList* PLinkList
    S4: 写函数int init_clist(PLinkList pclist int n) 进行循环表初始化
    S5:写函数void josephus_clist(PLinkList pclist int s int m) 进行循环表操作
    S6:函数中 LinkList josephus写三循坏分循环表总数x第y开始数第z 出局三函数
    do{printf(\t循环表总数x )scanf(d&x) }while(x<1)
    do{printf(\t第y开始数 )scanf(d&y) }while(y<1)
    do{printf(\t第z 出局 )scanf(d&z) }while(z<1)
    S7:然写判断if (init_clist(&josephusx)) josephus_clist(&josephusyz)
    else printf(溢出\n)
    S8:return 0
    S9:结束
    l 第三题:
    S1:定义结构体struct List{char number[20] char name[20] struct List* next }
    S2:typedef struct List* PList typedef struct List Data
    S3: 写增加空链表函数PList createNullList()
    S4:写增加号码函数int addNewPre(PList plistData x)
    S5:写删号码函数int delPosX(PList plistchar *name)
    S6:写查号码函数int lookAll(PList plist)
    S7:写查找号码函数 int findData(PList plistchar *name)
    S8:函数中定义PList p 接收createNullList()中返回值
    写菜单然菜单中调增删查查找4函数
    S9:return 0
    S10:结束
    五 程序运行测试实例

    l 第题图

    图例11

    l 第题图二

    图例12
    l 第题图三

    图例13

    l 第二题图1

    图例21






    l 第二题图2

    图例22
    l 第二题图3

    图例23






    l 第三题图:

    图例31
    l 第三题图二:

    图例32
    六 问题总结

    说明:提出程序设计中需进步深入考虑问题总结整设计取结果做简单分析总结设计程中心体会求实事求出现空话套话
    l 第2题序表模拟输出josephus问题点问题没调试出没写实验报告写采循坏链表模拟
    l 第3题点bug

    附录(源代码)
    明:粘贴设计程序源代码
    第源代码:
    #include
    #include
    typedef struct node *ptrNode
    typedef ptrNode LinkList 头结点
    typedef ptrNode Position中间节点
    typedef int ElementType
    struct node{
    ElementType Coefficient
    ElementType Exponent
    Position next
    }

    int IsEmpty(LinkList L)
    {
    return L>next NULL
    }
    LinkList creatList(int n)
    {
    LinkList headrp
    int coeexp
    head (struct node*)malloc(sizeof(struct node)) 生成新结点
    r head
    while(n){
    scanf(dd&coe&exp)
    p (struct node*)malloc(sizeof(struct node))
    p>Coefficient coe
    p>Exponent exp
    r>next p
    r p
    }
    r>next NULL
    return head
    }
    LinkList add_List(LinkList a LinkList b)
    { Position ha hb
    LinkList crp
    int temp
    ha a>next
    hb b>next
    c (struct node*)malloc(sizeof(struct node))
    r c
    while((ha NULL)&&(hb NULL)){
    p (struct node*)malloc(sizeof(struct node))
    if(ha>Exponent < hb>Exponent){
    p>Exponent hb>Exponent
    p>Coefficient hb>Coefficient
    hb hb>next
    r>next p
    r p
    }
    else if(ha>Exponent > hb>Exponent){
    p>Exponent ha>Exponent
    p>Coefficient ha>Coefficient
    ha ha>next
    r>next p
    r p
    }
    else{
    temp ha>Coefficient + hb>Coefficient
    if(temp 0){
    p>Exponent ha>Exponent
    p>Coefficient temp
    r>next p
    r p
    }
    hb hb>next
    ha ha>next
    }

    }
    if(ha NULL){

    while(hb NULL){
    p (struct node*)malloc(sizeof(struct node))
    p>Exponent hb>Exponent
    p>Coefficient hb>Coefficient
    hb hb>next
    r>next p
    r p
    }
    }

    if(hb NULL){

    while(ha NULL){
    p (struct node*)malloc(sizeof(struct node))
    p>Exponent ha>Exponent
    p>Coefficient ha>Coefficient
    ha ha>next
    r>next p
    r p
    }
    }

    r>next NULL

    return c

    }



    LinkList mul_List(LinkList a LinkList b)

    {

    Position ha hb
    LinkList ctempCrp
    ha a>next
    hb b>next
    c (struct node*)malloc(sizeof(struct node))

    c>next NULL
    c creatList(0)
    if(ha NULL || hb NULL){
    return c
    }
    while(ha NULL ){
    tempC (struct node*)malloc(sizeof(struct node))
    r tempC
    hb b>next
    while(hb NULL){
    p (struct node*)malloc(sizeof(struct node))
    p>Exponent ha>Exponent + hb>Exponent
    p>Coefficient ha>Coefficient*hb>Coefficient
    hb hb>next
    r>next p
    r p

    }
    r>next NULL
    c add_List(ctempC)
    tempHead tempC>next

    tempC>next NULL

    while(tempHead NULL){

    free(tempHead)

    tempHead tempHead>next

    }
    ha ha>next
    }
    return c
    }

    void printList(LinkList L)

    {
    LinkList hc
    int flag 0
    hc L>next
    if(hc NULL)
    printf(0 0)
    while(hc NULL){
    if(flag)
    printf( )
    else
    flag 1
    printf(d dhc>Coefficienthc>Exponent)
    hc hc>next
    }
    }

    int main(void)
    {
    int n1n2
    LinkList L1L2L3L4
    printf(第项式需输入项:\n)
    scanf(d&n1)
    printf(请输入d项项式:\nn1)
    L1 creatList(n1)
    printf(第二项式需输入项\n)
    scanf(d&n2)
    printf(请输入d项项式:\nn2)
    L2 creatList(n2)
    L3 add_List(L1L2)
    L4 mul_List(L1L2)
    printf(加法结果(两数字间分系数指数):\n)
    printList(L3)
    printf(\n)
    printf(法结果(两数字间分系数指数):\n)
    printList(L4)


    system(pause)
    return 0}

    l 第二题源代码
    #include
    #include
    #include

    #define Fal 0
    #define True 1




    struct Person元素类型
    {
    int num
    char name[8]
    }
    typedef struct Person DataType

    结点类型
    struct Node
    typedef struct Node* PNode

    struct Node
    {
    DataType info
    PNode link
    }
    typedef struct Node* LinkList
    typedef LinkList* PLinkList


    int init_clist(PLinkList pclist int n)循环表初始化
    {
    PNode pq
    int ijcpy_icount0
    char temp[10]
    q (PNode)malloc(sizeof(struct Node))

    if (q NULL) return Fal

    *pclist q
    (q>info)num1
    strcpy((q>info)name1)
    q>link q

    if (n 1) return True

    初始化(n)结点循环表
    for (i2 i {
    p (PNode)malloc(sizeof(struct Node))
    if (p NULL) return Fal
    (p>info)num i
    memset((p>info)name'\0'sizeof(char)*8)
    strcpy((p>info)name)
    cpy_i i
    memset(temp'\0'sizeof(char)*10)
    j0count0
    while (cpy_i 0)
    {
    temp[j] cpy_i10 + '0'
    cpy_i 10
    j++
    count++
    }
    j0
    while (countj>0)
    {
    char otemp[j]
    temp[j] temp[count1]
    temp[count1] o
    j++
    count
    }
    char* th &(p>info)name[2]
    strcpy(thtemp)

    p>link q>link
    q>link p
    q p
    }

    return True
    }

    循环表操作
    void josephus_clist(PLinkList pclist int s int m)
    {
    PNode p pre
    int i
    p *pclist
    找第s元素
    if (s1)
    {
    pre p
    p p>link
    while (p*pclist)
    {
    pre p
    p p>link
    }
    }
    else
    for (i1 i {
    pre p
    p p>link
    }
    while (pp>link)
    {
    for(i1i {
    pre p
    p p>link
    }
    printf(出局 s\n(p>info)name)
    if (*pclistp)
    *pclist p>link
    pre>link p>link
    free(p)
    p pre>link
    }
    printf(终剩 s\n(p>info)name)
    *pclist NULL
    free(p)
    }

    int main()
    {
    LinkList josephus
    int xyz
    do{
    printf(\t循环表总数x )
    scanf(d&x)
    }while(x<1)
    do{
    printf(\t第y开始数 )
    scanf(d&y)
    }while(y<1)
    do{
    printf(\t第z 出局 )
    scanf(d&z)
    }while(z<1)
    if (init_clist(&josephusx))
    josephus_clist(&josephusyz)
    else
    printf(溢出\n)
    getchar()
    system(pause)

    return 0
    }
    l 第三源代码
    #include
    #include
    #include
    struct List
    {
    char number[20]
    char name[20]
    struct List* next
    }
    typedef struct List* PList
    typedef struct List Data


    PList createNullList()增加空链表
    {
    PList plist (PList)malloc(sizeof(struct List))
    if (plistNULL)
    {
    printf(Building false\n)
    return NULL
    }
    else 初始化
    {
    memset(&plist>number'\0'sizeof(plist>number))
    memset(&plist>name'\0'sizeof(plist>name))
    plist>next NULL
    }

    return plist
    }


    int addNewPre(PList plistData x)增加
    {
    PList data (PList)malloc(sizeof(PList))
    PList t plist
    if (t>next NULL)
    while (true)
    {
    if (strcmp(t>next>namexname)0)
    t t>next
    else if (t>next NULL)
    break
    else
    {
    printf(输入重复\n)
    return 1
    }
    }
    strcpy(data>numberxnumber)
    strcpy(data>namexname)
    data>next plist>next
    plist>next data
    printf(增加成功(ss)\ndata>namedata>number)

    return 0
    }


    int delPosX(PList plistchar *name)删
    {
    PList del
    PList t plist
    查找位置
    while (strcmp(t>next>namename)0)
    t t>next
    del t>next
    t>next t>next>next
    printf(Delete success(s)\ndel>number)
    free(del)

    return 0
    }


    int lookAll(PList plist)查
    {
    int i1
    PList t plist>next
    if (plist>nextNULL)
    {
    printf(空\n)
    return 0
    }
    else
    {
    while(t>nextNULL)
    {
    int
    printf(ds s\ni++t>namet>number)
    t t>next
    }
    printf(ds s\nit>namet>number)
    }

    return 0
    }


    int findData(PList plistchar *name)查找输出
    {
    int count0
    PList t plist
    printf(查找结果\n)
    while (tNULL)
    {
    if (strcmp(t>namename)0)
    {
    printf(s s\nt>namet>number)
    t t>next
    count++
    }
    else
    t t>next
    }
    if (count 0)
    {
    printf(d位联系\ncount)
    return 0
    }
    else
    printf(未找(s)信息\nname)

    return 1
    }



    int main()
    {
    PList p createNullList()
    Data t
    char ch1

    while (ch '0')
    {
    printf(\t 通讯录\t\n)
    printf(\n)
    printf(\t1查联系\n)
    printf(\t2新建\n)
    printf(\t3删\n)
    printf(\t4查找\n)
    printf(\n )
    ch getchar()

    switch(ch)
    {
    case '1'
    lookAll(p)
    break
    case '2'
    printf(name )
    scanf(s&tname)
    printf(number )
    scanf(s&tnumber)
    addNewPre(pt)
    break
    case '3'
    printf(name )
    scanf(s&tname)
    delPosX(ptname)
    break
    case '4'
    printf(name )
    scanf(s&tname)
    findData(ptname)
    break
    defaultbreak
    }
    getchar()

    if (ch'0')
    break
    else
    system(pause)

    }

    return 0
    }
    总体格式求:标题求宋体三号加粗两倍行距段前05行段05行正文求宋体四15倍行距段前05行流程图求居中实验结果图求居中图例图11 实验结果图图例求位实验结果图正方程序代码求宋体五号15倍行距段前段均0行代码必代码解释


    文档香网(httpswwwxiangdangnet)户传

    《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
    该内容是文档的文本内容,更好的格式请下载文档

    下载文档到电脑,查找使用更方便

    文档的实际排版效果,会与网站的显示效果略有不同!!

    需要 5 香币 [ 分享文档获得香币 ]

    下载文档

    相关文档

    《高级语言程序设计》实验报告

    设计一种用单链表存储多项式的结构(每个结点存储一项的系数和指数,类型都为int)并编写一个产生多项式链表的函数和一个实现两个多项式相加和相乘的函数。

    5年前   
    3481    0

    C语言程序设计实验报告

    C语言程序设计实验报告  实验名称 计算出1000以内10个最大素数之和   实验目的   1、熟练掌握if、if…else、if…else if语句和witch语句格式及使用方法,掌握if语...

    10年前   
    922    0

    铜陵学院C语言程序设计实验报告

    《C语言程序设计》 实验报告第二学期班 级 学 号姓 名指导教师实验一 Visual C++ 6.0编程环境与C语言程序的调试过程一、实验学时2 学时。二、...

    11个月前   
    227    0

    C语言实验报告《逻辑结构程序设计》

    C语言实验报告《逻辑结构程序设计》  学号:__________    姓名:__________    班级:__________    日期:__________   指导教师:_____...

    12年前   
    729    0

    c语言实验报告

    c语言实验报告  学号:__________    姓名:__________    班级:__________    日期:__________   指导教师:__________    成...

    11年前   
    773    0

    C语言实验报告《指针》

    C语言实验报告《指针》  学号:__________    姓名:__________    班级:__________    日期:__________   指导教师:__________ ...

    11年前   
    929    0

    C语言实验报告《数组》

    C语言实验报告《数组》  学号:__________    姓名:__________    班级:__________    日期:__________  指导教师:__________  ...

    11年前   
    871    0

    国开电大《C语言程序设计》答案

    形考1在每个C语言程序中都必须包含有这样一个函数,该函数的函数名为(  )。选择一项:A. main 正确恭喜你,答对啦!!B. MAIN C. name D. function .题目2正确...

    11个月前   
    394    1

    C语言程序设计习题试题集

    《C语言程序设计》精品课件试题目录(按住CTRL键点击超链)单项选择题………………………第002页阅读程序题………………………第018页程序填空题………………………第039页编写程序题…………...

    1年前   
    3010    0

    C语言程序设计说课教案

    《C语言程序设计》说课教案从以下方面说明:一、 课程性质、地位二、 教学对象分析及要求三、 课程体系四、 课程的重点、难点及突破五、 教学方法与教学手段六、 学生考核七、 教学计划一、 课程性...

    1年前   
    319    0

    《JAVA语言程序设计》试题及答案3

    《JAVA语言程序设计》试题及答案3《JA V A语言程序设计》试题及答案3一、单选题1、下列程序段执行后的结果是( )。String s = new String(“abcdefg“);fo...

    3年前   
    953    0

    C语言程序设计实验教案

     《高级语言程序设计》 实验指导书 实验一 顺序结构程序设计 一、实验目的及要求 1. 掌握C语言中使用最多的一种语句—...

    5年前   
    1453    0

    C语言程序设计形考任务

    假定有“struct BOOK{char title[40]; float price;}; struct BOOK book;”,则不正确的语句为( )。选择一项: a. struct ...

    4年前   
    1463    0

    c语言高级面试题

    整个测试遵循以下的约定:u       假定在所有的程序中必须的头文件都已经被正确包含。考虑如下的数据类型:u       char 为1个字节u       int 为4个字节u      ...

    1个月前   
    76    0

    C语言实验报告《函数》

    C语言实验报告《函数》  学号:__________    姓名:__________    班级:__________    日期:__________  指导教师:__________  ...

    12年前   
    1328    0

    C语言实验报告《综合实验》

    C语言实验报告《综合实验》  学号:__________    姓名:__________    班级:__________    日期:__________  指导教师:__________...

    10年前   
    853    0

    面向对象程序设计(C++)实验报告

    面向对象程序设计(C++)实验报告姓名:学院:数学与计算机学院 班级:10级计算机大类班 学号:实验5 单继承一、实验目的1.掌握派生的类别与方式; ...

    3年前   
    1062    0

    国家开放大学电大《C语言程序设计》《高级英语阅读(1)》网络课形考网考作业(合集)答案

    国家开放大学电大《C语言程序设计》《高级英语阅读(1)》网络课形考网考作业(合集)答案《C语言程序设计》网络课答案形考任务1一、选择题(共40分,每小题2分)题目1在每个C语言程序中都必须包含...

    4年前   
    558    0

    国开电大《C语言程序设计》形考任务3

    论文和作业参考答案联系qq2019910207或咨询微信15927685953,为了准确获取需要资料请在付费前加qq或微信咨询,请认真核对是您需要的题目后再付费!形考任务三题目1在下面的函数声...

    1个月前   
    69    0

    《Java语言程序设计-基础篇》答案-第03章

    《Java语言程序设计-基础篇》答案-第03章第3章 控制语句复习题3.1 答:if(i % 2 == 0)System.out.println(“偶数”);elseSystem.out.pr...

    3年前   
    825    0