首页 范文大全 古典文学 职场知识 中国文学 公文书信 外国名著 寓言童话 百家讲坛 散文/诗歌 美文欣赏 礼仪知识 民俗风情
  • 工作总结
  • 工作计划
  • 心得体会
  • 竞聘演讲
  • 会议发言
  • 爱国演讲
  • 就职演说
  • 开业开幕
  • 思想学习
  • 征文演讲
  • 经验材料
  • 述职报告
  • 调研报告
  • 工作汇报
  • 年终总结
  • 申报材料
  • 学习体会
  • 企划方案
  • 活动方案
  • 技巧经验
  • 模板范例
  • 思想宣传
  • 经济工作
  • 工作报告
  • 组织人事
  • 反腐倡廉
  • 慰问贺电
  • 先进事迹
  • 思想汇报
  • 入党申请书
  • 党会发言
  • 先进性教育
  • 入团申请书
  • 个人简历
  • 演讲稿
  • 调查报告
  • 实习报告
  • 和谐社会
  • 观后感
  • 读后感
  • 作文范文
  • 自我鉴定
  • 讲话稿
  • 自查报告
  • MATLAB语言程序设计实验报告

    时间:2021-03-11 18:07:34 来源:蒲公英阅读网 本文已影响 蒲公英阅读网手机站

    相关热词搜索:实验 语言程序设计 报告

    MATLAB语言的程序设计实验报告 本文关键词:程序设计,语言,实验,报告,MATLAB

    MATLAB语言的程序设计实验报告 本文简介:MATLAB语言的程序设计一、实验目的及要求1.掌握一些矩阵运算的基本函数应用方法2.熟悉MATLAB程序编辑与设计环境3.掌握各种编程语句语法规则及程序设计方法4.会编写程序M文件和函数M文件5.初步掌握程序的调式方法二、实验内容1.掌握以下矩阵操作函数实际给定一些数据后,使用各种函数计算,观察运

    MATLAB语言的程序设计实验报告 本文内容:

    MATLAB语言的程序设计

    一、实验目的及要求

    1.掌握一些矩阵运算的基本函数应用方法

    2.熟悉MATLAB程序编辑与设计环境

    3.掌握各种编程语句语法规则及程序设计方法

    4.会编写程序M文件和函数M文件

    5.初步掌握程序的调式方法

    二、实验内容

    1.掌握以下矩阵操作函数

    实际给定一些数据后,使用各种函数计算,观察运算结果:

    zeros(n)

    生成nxn的零阵

    zeros(n,m)生成n行m列的零阵

    ones(n,m)

    生成n行m列的全1阵

    eye(n)

    生成nxn的单位阵

    randn(n,m)

    生成元素为正态分布随机阵

    x=[]

    生成空矩阵

    1、

    下列运算是否合法,为什么?如合法,结果是多少?

    (1)

    result1

    =

    a

    答>>

    result1=a

    result1

    =

    1

    4

    2

    5

    3

    6

    (2)

    result2

    =

    a

    b

    错误

    (3)

    result3

    =

    a

    +

    b

    答>

    result3=a+b

    result3

    =

    3

    6

    2

    5

    8

    11

    (4)

    result4

    =

    b

    d

    答>>

    result4=b*d

    result4

    =

    31

    22

    22

    40

    49

    13

    (5)

    result5

    =

    [b

    ;

    c

    ]

    d

    答>>

    result5=[b;c

    ]*d

    result5

    =

    31

    22

    22

    40

    49

    13

    -5

    -8

    7

    (6)

    result6

    =

    a

    .

    b

    答>>

    result6

    =

    a.*b

    result6

    =

    2

    8

    -3

    4

    15

    30

    (7)

    result7

    =

    a

    .

    /

    b

    答>>

    result7=a./b

    result7

    =

    0.5000

    0.5000

    -3.0000

    4.0000

    1.6667

    1.2000

    (8)

    result8

    =

    a

    .

    c

    错误

    (9)

    result9

    =

    a

    .

    /

    b

    答>>

    result9=a./b

    result9

    =

    2.0000

    2.0000

    -0.3333

    0.2500

    0.6000

    0.8333

    (10)

    result10

    =

    a

    .

    ^2

    答>>

    result10=a.^2

    result10

    =

    1

    4

    9

    16

    25

    36

    (11)

    result11

    =

    a

    ^2

    错误

    (12)

    result11

    =

    2

    .

    ^

    a

    答>>

    result12=2.^a

    result12

    =

    2

    4

    8

    16

    32

    64

    2、关系运算与逻辑运算

    已知a=20,b=-2,c=0,d=1

    (1)

    r1

    =

    a

    >

    b

    答>>

    r1=a>b

    r1

    =

    1

    (2)

    r2

    =

    a

    >

    b

    if

    n1

    if

    rem(n,2)==0

    n=n/2;

    else

    n=3*n+1;

    end

    a=[a,n];

    end

    a

    end

    答Enter

    n,negative

    quits:15

    a

    =

    Columns

    1

    through

    16

    15

    46

    23

    70

    35

    106

    53

    160

    80

    40

    20

    10

    5

    16

    8

    4

    Columns

    17

    through

    18

    2

    1

    又Enter

    n,negative

    quits:72

    a

    =

    Columns

    1

    through

    16

    72

    36

    18

    9

    28

    14

    7

    22

    11

    34

    17

    52

    26

    13

    40

    20

    Columns

    17

    through

    23

    10

    5

    16

    8

    4

    2

    1

    2、

    编程求满足的最小m值。

    答i=1;

    s=1;

    n=0;

    while

    n<10000

    s=s*2;

    n=n+s;

    i=i+1;

    end

    i

    结果:i

    =

    14

    3、,求y=?(用format

    long查看y的值)

    i=-10;

    y=0;

    while

    i<11

    y=y+2.^i;

    i=i+1;

    end

    format

    long

    y

    结果:

    y

    =

    2.047999023437500e+003

    篇2:C程序设计设计性实验报告

    C程序设计设计性实验报告 本文关键词:程序设计,实验,报告,设计

    C程序设计设计性实验报告 本文简介:C++程序设计设计性实验C++程序设计设计性实验报告实验项目名称:高级计算器设计与开发专业班级:数学061;姓名:冯凯;学号200612010115实验起止日期:起于2008年11月1日止于2008年12月10日实验目的:1.学会用C++语言和利用数据结构中的堆栈实现表达式的解析与计算。2.学会使用

    C程序设计设计性实验报告 本文内容:

    C++程序设计设计性实验

    C++程序设计设计性实验报告

    实验项目名称:高级计算器设计与开发

    专业班级:

    数学061

    ;姓名:

    ;学号

    200612010115

    实验起止日期:起于

    2008

    11

    月1日止于

    2008

    12

    月10日

    实验目的:

    1.学会用C++语言和利用数据结构中的堆栈实现表达式的解析与计算。

    2.学会使用动态链接库技术进行编程;学会编辑、编译、运行MFC应用程序的基本

    过程,并开发一个可以进行表达式运算的高级计算器。

    实验要求:

    1.

    能处理双精度型数值的加、减、乘、除的表达式计算。

    2.编程中使用了动态连接库技术。

    开发环境要求:

    软件环境:windows98/windowsXP/windows2000,Visual

    C++

    硬件环境:计算机(Pen4CPU,256MRAM,60G以上硬盘,输入输出设备)

    技术文档要求:

    按照软件工程技术文档编写要求进行。要求流程图绘制规范,模块功能描述清晰,数据字典齐全。

    实验内容:

    1

    C++语言的顺序结构,分支结构,循环结构,函数,结构体,指针。

    2

    数据结构中的堆栈存贮结构及其操作的实现。

    实验具体方案:

    按照系统设计要求,用Visual

    C++设计和开发一个MFC应用程序---高级计算器,提交由需求分析;系统设计说明(包括主菜单、子菜单、模块功能简介、数据字典、系统结构图);系统技术文档

    (包括系统各模块主要流程图,软件总体测试方案与测试记录、局部测试方案与测试记录、软件调试和修改记录、测试结论、运行情况记录),系统使用说明书,源程序代码为附录构成的实验报告。

    需求分析:

    普通的功能简单的仅能进行四则运算的计算工具已经不能满足需要,需要一种能进行多种计算工具。而windows自带的计算器不能处理表达式这是一个缺陷,为此开发一个能处理表达式运算的高级计算器是十分必要的,这为计算提高了更大的方便,可以大幅度提高计算效率。

    系统设计说明:(包括主菜单、子菜单、模块功能简介、数据字典、系统结构图)

    主菜单主要包含:

    操作说明、相关主题、退出。

    整个程序的模块组成:

    (1)

    Windows基于对话框的资源文件模块。

    (2)

    动态链接库模块,主要提供了表达式的解析与计算。

    (3)

    其他功能模块如开平方,取平方,进制转换等。

    数据字典

    m_edit1

    //编辑框变量,用于显示输入输出

    CString

    str1,str2,str3

    //中间临时字符串变量

    char

    s[70],s2[70],buffer[20];

    //用于CString字符串的转换以及将double型数据转

    换为CString型字符串。

    stack

    //结构体类型

    ElemTypestack;

    //存栈元素

    Int

    top

    //存栈顶元素的下标位置

    int

    MaxSiz//存stack数组长度。

    void

    Initiatestack(Stack

    #endif

    double

    x,y,z;

    ///////判断优先级的函数

    extern

    int

    Precedence(char

    op);

    ///////将中缀表达式转换为后缀表达式,中缀在str1中,后缀在str2中

    extern

    int

    change(char*

    str1,char*str2);

    ///////计算后缀表达式的值///////////////////////

    extern

    double

    compute(charstr);

    ///////////////////////////进制转换函数//////////////////////////////

    extern

    double

    tranfrom(double

    num,int

    r);

    //

    CAboutDlg

    dialog

    used

    for

    App

    About

    class

    CAboutDlg

    :

    public

    CDialog

    {

    public:

    CAboutDlg();

    //

    Dialog

    Data

    //{{AFX_DATA(CAboutDlg)

    enum

    {

    IDD

    =

    IDD_ABOUTBOX

    };

    //}}AFX_DATA

    //

    ClassWizard

    generated

    virtual

    function

    overrides

    //{{AFX_VIRTUAL(CAboutDlg)

    protected:

    virtual

    void

    DoDataExchange(CDataExchange*

    pDX);

    //

    DDX/DDV

    support

    //}}AFX_VIRTUAL

    //

    Implementation

    protected:

    //{{AFX_MSG(CAboutDlg)

    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()

    };

    CAboutDlg::CAboutDlg()

    :

    CDialog(CAboutDlg::IDD)

    {

    //{{AFX_DATA_INIT(CAboutDlg)

    //}}AFX_DATA_INIT

    }

    void

    CAboutDlg::DoDataExchange(CDataExchange*

    pDX)

    {

    CDialog::DoDataExchange(pDX);

    //{{AFX_DATA_MAP(CAboutDlg)

    //}}AFX_DATA_MAP

    }

    BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)

    //{{AFX_MSG_MAP(CAboutDlg)

    //

    No

    message

    handlers

    //}}AFX_MSG_MAP

    END_MESSAGE_MAP()

    /////////////////////////////////////////////////////////////////////////////

    //

    CCalcDlg

    dialog

    CCalcDlg::CCalcDlg(CWnd*

    pParent

    /*=NULL*/)

    :

    CDialog(CCalcDlg::IDD,pParent)

    {

    //{{AFX_DATA_INIT(CCalcDlg)

    m_edit1

    =

    _T(““);

    //}}AFX_DATA_INIT

    //

    Note

    that

    LoadIcon

    does

    not

    require

    a

    subsequent

    DestroyIcon

    in

    Win32

    m_hIcon

    =

    AfxGetApp()->LoadIcon(IDR_MAINFRAME);

    }

    void

    CCalcDlg::DoDataExchange(CDataExchange*

    pDX)

    {

    CDialog::DoDataExchange(pDX);

    //{{AFX_DATA_MAP(CCalcDlg)

    DDX_Text(pDX,IDC_EDIT1,m_edit1);

    //}}AFX_DATA_MAP

    }

    BEGIN_MESSAGE_MAP(CCalcDlg,CDialog)

    //{{AFX_MSG_MAP(CCalcDlg)

    ON_WM_SYSCOMMAND()

    ON_WM_PAINT()

    ON_WM_QUERYDRAGICON()

    ON_BN_CLICKED(IDC_1,OnNO1)

    ON_BN_CLICKED(IDC_2,OnNO2)

    ON_BN_CLICKED(IDC_3,OnNO3)

    ON_BN_CLICKED(IDC_4,OnNO4)

    ON_BN_CLICKED(IDC_5,OnNO5)

    ON_BN_CLICKED(IDC_6,OnNO6)

    ON_BN_CLICKED(IDC_7,OnNO7)

    ON_BN_CLICKED(IDC_8,OnNO8)

    ON_BN_CLICKED(IDC_0,OnN0)

    ON_BN_CLICKED(IDC_9,OnNO9)

    ON_BN_CLICKED(IDC_DIAN,OnDOT)

    ON_BN_CLICKED(IDC_ADD,OnADD)

    ON_BN_CLICKED(IDC_DENG,OnDENG)

    ON_BN_CLICKED(IDC_clear,Onclear)

    ON_BN_CLICKED(IDC_SUB,OnSub)

    ON_BN_CLICKED(IDC_CHENG,OnCheng)

    ON_BN_CLICKED(IDC_CHU,OnChu)

    ON_BN_CLICKED(IDC_sqrt,Onsqrt)

    ON_BN_CLICKED(IDC_powe,Onpowe)

    ON_BN_CLICKED(IDC_DUISHU,OnDuishu)

    ON_BN_CLICKED(IDC_BUTTON1,Ondelete)

    ON_BN_CLICKED(IDC_BUTTON3,Onyoukuohao)

    ON_BN_CLICKED(IDC_BUTTON4,Onzuokuohao)

    ON_EN_CHANGE(IDC_EDIT1,OnChangeEdit1)

    ON_BN_CLICKED(IDC_BUTTON2,OnER_jin_zhi)

    ON_BN_CLICKED(IDC_BUTTON5,Onba_jin_zhi)

    ON_BN_CLICKED(IDC_BUTTON6,Onshi_liu_jin_zhi)

    ON_BN_CLICKED(IDC_BUTTON7,OnCOS)

    ON_BN_CLICKED(IDC_BUTTON8,Onsin)

    ON_BN_CLICKED(IDC_BUTTON9,OnOP)

    ON_BN_CLICKED(IDC_BUTTON10,OnZhuti)

    ON_BN_CLICKED(IDC_BUTTON11,Onexit)

    //}}AFX_MSG_MAP

    END_MESSAGE_MAP()

    /////////////////////////////////////////////////////////////////////////////

    //

    CCalcDlg

    message

    handlers

    BOOL

    CCalcDlg::OnInitDialog()

    {

    CDialog::OnInitDialog();

    //

    Add

    “About.“menu

    item

    to

    system

    menu.

    //

    IDM_ABOUTBOX

    must

    be

    in

    the

    system

    command

    range.

    ASSERT((IDM_ABOUTBOX

    ASSERT(IDM_ABOUTBOX

    AppendMenu(MF_SEPARATOR);

    pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);

    }

    }

    //

    Set

    the

    icon

    for

    this

    dialog.

    The

    framework

    does

    this

    automatically

    //

    when

    the

    application

    s

    main

    window

    is

    not

    a

    dialog

    SetIcon(m_hIcon,TRUE);//

    Set

    big

    icon

    SetIcon(m_hIcon,FALSE);//

    Set

    small

    icon

    //

    TODO:

    Add

    extra

    initialization

    here

    return

    TRUE;

    //

    return

    TRUE

    unless

    you

    set

    the

    focus

    to

    a

    control

    }

    void

    CCalcDlg::OnSysCommand(UINT

    nID,LPARAM

    lParam)

    {

    if

    ((nID

    dlgAbout.DoModal();

    }

    else

    {

    CDialog::OnSysCommand(nID,lParam);

    }

    }

    //

    If

    you

    add

    a

    minimize

    button

    to

    your

    dialog,you

    will

    need

    the

    code

    below

    //

    to

    draw

    the

    icon.

    For

    MFC

    applications

    using

    the

    document/view

    model,//

    this

    is

    automatically

    done

    for

    you

    by

    the

    framework.

    void

    CCalcDlg::OnPaint()

    {

    if

    (IsIconic())

    {

    CPaintDC

    dc(this);

    //

    device

    context

    for

    painting

    SendMessage(WM_ICONERASEBKGND,(WPARAM)

    dc.GetSafeHdc(),0);

    //

    Center

    icon

    in

    client

    rectangle

    int

    cxIcon

    =

    GetSystemMetrics(SM_CXICON);

    int

    cyIcon

    =

    GetSystemMetrics(SM_CYICON);

    CRect

    rect;

    GetClientRect(

    int

    x

    =

    (rect.Width()

    -

    cxIcon

    +

    1)

    /

    2;

    int

    y

    =

    (rect.Height()

    -

    cyIcon

    +

    1)

    /

    2;

    //

    Draw

    the

    icon

    dc.DrawIcon(x,y,m_hIcon);

    }

    else

    {

    CDialog::OnPaint();

    }

    }

    //

    The

    system

    calls

    this

    to

    obtain

    the

    cursor

    to

    display

    while

    the

    user

    drags

    //

    the

    minimized

    window.

    HCURSOR

    CCalcDlg::OnQueryDragIcon()

    {

    return

    (HCURSOR)

    m_hIcon;

    }

    void

    CCalcDlg::OnNO1()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“1“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO2()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“2“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO3()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“3“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO4()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“4“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO5()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“5“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO6()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“6“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO7()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“7“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO8()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“8“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnN0()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“0“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnNO9()

    {

    m_edit1+=“9“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnDOT()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“.“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnADD()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“+“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnDENG()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    char

    s[70],s2[70],buffer1[20];double

    r;CString

    str1,str2,str3;int

    i=0;

    str1=m_edit1;

    strncpy(s,(LPCTSTR)str1,sizeof(s));

    s[sizeof(s)-1]=

    /0

    ;

    if(str1.Left(1)==“+“||s[0]==

    -

    ||s[0]==

    ||s[0]==

    /

    ||s[0]==

    .

    )

    {str2.Format(“/n抱

    歉!/n不

    式!

    /n请

    入“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    for(i=0;s[i]!=

    /0

    ;i++)

    {

    if((s[i]==

    +

    ||s[i]==

    -

    ||s[i]==

    ||s[i]==

    /

    )

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    }

    change(s,s2);

    if(change(s,s2)==0)

    {

    str2.Format(“/n输

    !

    /n请

    入“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;}

    r=compute(s2);

    if(r==sqrt(2))

    {

    str2.Format(“/n输

    !

    /n请

    入“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;}

    _gcvt(r,8,buffer1);

    for(i=1;buffer1[i]!=

    /0

    ;i++)

    {

    if(buffer1[i]==

    .

    }

    m_edit1=(CString)buffer1;

    label:

    UpdateData(false);

    }

    void

    CCalcDlg::Onclear()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1=_T(““);

    UpdateData(false);

    }

    void

    CCalcDlg::OnSub()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“-“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnCheng()

    {

    m_edit1+=“*“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnChu()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“/“;

    UpdateData(false);

    }

    void

    CCalcDlg::Onsqrt()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    chars1,buffer1[20];CString

    str1,str2,str3;int

    i;

    str1=m_edit1;

    str2=str1;

    str3=str1;

    if(str2.Right(1)==“B“||str2.Right(1)==“o“||str2.Right(1)==“H“||str3.Left(1)==“B“||str3.Left(1)==“o“||str3.Left(1)==“H“)

    {

    {

    str2.Format(“/n!

    /n请

    入“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;}

    }

    OnDENG();

    //调用等号子过程

    x=strtod(m_edit1,if(x<0)

    {

    str2.Format(“/n负

    “);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    y=sqrt(x);

    _gcvt(y,16,buffer1);

    for(i=0;buffer1[i]!=

    /0

    ;i++)

    {

    if(buffer1[i]==

    .

    }

    m_edit1=(CString)buffer1;

    label:UpdateData(false);

    }

    void

    CCalcDlg::Onpowe()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    chars,buffer1[20];CString

    str1,str2,str3;int

    i=0;

    str1=m_edit1;

    str2=str1;

    str3=str1;

    if(str2.Right(1)==“B“||str2.Right(1)==“o“||str2.Right(1)==“H“||str3.Left(1)==“B“||str3.Left(1)==“o“||str3.Left(1)==“H“)

    {

    {

    str2.Format(“/n!

    /n请

    入“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;}

    }

    OnDENG();

    //调用等号子过程

    x=strtod(m_edit1,y=pow(x,2);

    _gcvt(y,16,buffer1);

    for(i=0;buffer1[i]!=

    /0

    ;i++)

    {

    if(buffer1[i]==

    .

    }

    m_edit1=(CString)buffer1;

    label:UpdateData(false);

    }

    void

    CCalcDlg::OnDuishu()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    chars1,buffer1[20];CString

    str1,str2,str3;int

    i=0;

    str1=m_edit1;

    str2=str1;

    str3=str1;

    if(str2.Right(1)==“B“||str2.Right(1)==“o“||str2.Right(1)==“H“||str3.Left(1)==“B“||str3.Left(1)==“o“||str3.Left(1)==“H“)

    {

    {

    str2.Format(“/n!

    /n请

    入“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    str2=_T(““);

    goto

    label;}

    }

    OnDENG();

    //调用等号子过程

    x=strtod(m_edit1,if(x<0)

    {

    str2.Format(“/n负

    “);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    y=log10(x);

    _gcvt(y,6,buffer1);

    for(i=0;buffer1[i]!=

    /0

    ;i++)

    {

    if(buffer1[i]==

    .

    }

    m_edit1=(CString)buffer1;

    label:UpdateData(false);

    }

    void

    CCalcDlg::Ondelete()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    CString

    str1,str2,str3;

    str1=m_edit1;

    str1=str1.Left(str1.GetLength()-1);

    m_edit1=str1;

    UpdateData(false);

    }

    void

    CCalcDlg::Onyoukuohao()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“)“;

    UpdateData(false);

    }

    void

    CCalcDlg::Onzuokuohao()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    m_edit1+=“(“;

    UpdateData(false);

    }

    void

    CCalcDlg::OnChangeEdit1()

    {

    //

    TODO:

    If

    this

    is

    a

    RICHEDIT

    control,the

    control

    will

    not

    //

    send

    this

    notification

    unless

    you

    override

    the

    CDialog::OnInitDialog()

    //

    function

    and

    call

    CRichEditCtrl().SetEventMask()

    //

    with

    the

    ENM_CHANGE

    flag

    ORed

    into

    the

    mask.

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    }

    void

    CCalcDlg::OnER_jin_zhi()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    double

    x1,x2,*p;int

    i=0,j=0,k=0;CString

    str1,str2,str3;

    chars1,buffer1[35];

    str1=m_edit1;

    str2=str1;

    str3=str1;

    if(str2.Right(1)==“B“||str2.Right(1)==“o“||str2.Right(1)==“H“||str3.Left(1)==“B“||str3.Left(1)==“o“||str3.Left(1)==“H“)

    {

    {

    str2.Format(“/n!

    “);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;}

    }

    char

    s[100];

    strncpy(s,(LPCTSTR)str1,sizeof(s));

    s[str1.GetLength()-1]=

    /0

    ;

    for(i=0;s[i]!=

    /0

    ;i++)

    {

    if(s[i]==

    .

    )

    {

    str2.Format(“抱歉不能处理带小数点的数!/n

    请输入一个整数试试“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    else

    if(s[i]==

    ||s[i]==

    /

    )

    {str2.Format(“抱歉不能处理这类表达式!/n

    请输入一个不带任何符号的整数试试“);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    }

    for(i=0;s[i]!=

    /0

    ;i++)

    {

    if((s[i]==

    +

    ||s[i]==

    -

    ||s[i]==

    ||s[i]==

    /

    )

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;

    }

    }

    m_edit1=_T(““);

    x1=strtod(str1,if(x1<0)

    x2=-x1;

    else

    x2=x1;

    p=tranfrom(x2,2);

    for(i=0;p[i]!=

    #

    ;i++)

    {_gcvt(p[i],32,buffer1);

    for(j=0;j<35;j++)

    if(buffer1[j]==

    .

    )

    {

    buffer1[j]=buffer1[j+1];

    m_edit1+=(CString)buffer1;

    }

    }

    if(x1<0)

    m_edit1=“-“+m_edit1;

    m_edit1+=“B“;

    label

    :UpdateData(false);

    }

    void

    CCalcDlg::Onba_jin_zhi()

    {

    //

    TODO:

    Add

    your

    control

    notification

    handler

    code

    here

    double

    x1,x2,*p;int

    i=0,j=0;CString

    str1,str2,str3;

    chars1,buffer1[35];

    str1=m_edit1;

    str2=str1;

    str3=str1;

    if(str2.Right(1)==“B“||str2.Right(1)==“o“||str2.Right(1)==“H“||str3.Left(1)==“B“||str3.Left(1)==“o“||str3.Left(1)==“H“)

    {

    {

    str2.Format(“/n!

    “);

    MessageBox(str2,“冯凯温馨提示“);

    m_edit1=_T(““);

    goto

    label;}

    }

    char

    s[35];

    strncpy(s,(LPCTSTR)str1,sizeof(s));

    s[sizeof(s)-1]=

    /0

    ;

    for(i=0;s[i]!=

    /0

    ;i++)

    {

    if(s[i]==

    .

    )

    {

    str2.Format(“抱歉不能处理带小数点的数!/n

    请输入一个整数试试“);

    MessageBox(str2,“冯凯温馨

    篇3:C语言程序设计实验报告(6)

    C语言程序设计实验报告(6) 本文关键词:实验,语言程序设计,报告

    C语言程序设计实验报告(6) 本文简介:贵阳学院机电系实验报告课程名称:指导教师:年级:专业:学生姓名:学号:20——20学年第学期填写要求一、对于演示性实验,要写出心得体会(字数不少于800字)。二、对于验证性实验(操作型,不属于程序设计型),要收集数据,对数据进行处理,并绘制曲线和写出实验总结(不少于50字)。三、对于设计性实验,(操

    C语言程序设计实验报告(6) 本文内容:

    贵阳学院

    机电系实验报告

    课程名称:

    指导教师:

    级:

    业:

    学生姓名:

    号:

    20

    ——20

    学年第

    学期

    一、对于演示性实验,要写出心得体会(字数不少于800字)。

    二、对于验证性实验(操作型,不属于程序设计型),要收集数据,对数据进行处理,并绘制曲线和写出实验总结(不少于50字)。

    三、对于设计性实验,(操作型,不属于程序设计型),要给设计思路,完成“二”中的任务,分析设计的规范性和合理性。

    四、对于程序设计型实验,要写出源程序,运行结果和实验总结(不少于50字)。

    实验一(预备实验)

    一、

    实验项目名称:

    C语言的运行环境和运行C程序的方法

    二、

    实验时间:

    三、

    实验地点:

    四、

    实验目的:

    1.

    了解所用的计算机系统的基本操作方法,学会独立使用该系统。

    2.

    了解在该系统上如何编辑、编译、连接和运行一个C程序。

    3.

    通过运行简单的C程序,初步了解C源程序的特点。

    五、

    主要的实验所需仪器、设备:PC机。

    六、

    实验内容与步骤:

    1.

    检查所用的计算机系统是否已安装了C编译系统并确定它所在的子目录。

    2.

    进入所用的集成环境。

    3.

    熟悉集成环境的界面和有关菜单的使用方法。

    4.

    输入并运行一个简单的、正确的程序。

    i.

    输入下面的程序

    #include

    void

    main(

    )

    {

    printf(“This

    is

    a

    program./n”);

    }

    ii.

    编译源程序,观察编译信息,如出现错误,找出原因,继续编译,如无错,进行连接。

    iii.

    如连接无误,运行程序,分析运行结果。

    5.

    输入并编辑一个有错误的C程序。

    i.

    输入以下程序

    #include

    void

    main(

    )

    {

    int

    a,b,sum;

    a=123;

    b=456;

    sum=a+b

    print(“sum

    si

    %d/n”,sum);

    }

    ii.

    编译程序,错误信息有:

    iii.

    编译成功,连接程序,错误信息有:

    iv.

    连接成功,使程序运行,运行结果:

    v.

    分析结果正误:

    vi.

    将调试好的程序保存在自己的用户目录中,文件名自定。

    vii.

    关闭文件,再将文件读入,检查窗口中的内容是否是刚才存盘的程序。

    viii.

    关闭所有的集成环境,用Windows中的“我的电脑”找到刚才使用的用户子目录,浏览其中文件,看有无刚才保存的后缀为.c和.exe的文件。

    6.

    上机运行本章例题1.3。

    七、

    本次上机实验的心得。

    八、

    理论支撑:《C语言程序设计》第一章

    本次实验成绩

    • 范文大全
    • 职场知识
    • 精美散文
    • 名著
    • 讲坛
    • 诗歌
    • 礼仪知识