zoukankan      html  css  js  c++  java
  • 第二次作业及总结——数据类型和运算符

    一.两道程序

    第一道

    #include<stdio.h>
    #include<math.h>
    int main(void)
    {
    int money,year;
    double rate,sum;

    printf("Enter money:");
    scanf("%d",&money);
    printf("Enter year:");
    scanf("%d",&year);
    printf("Enter rate:");
    scanf("%lf",&rate);
    sum=money*pow(1+rate,year);
    printf("sum=%.2f ",sum);
    return 0;
    }

    第二道

    #include<stdio.h>
    #include<math.h>
    int main(void)
    {
    double x,y;
    printf("Enter x: ");
    scanf("%lf",&x);
    if(x<0){
    y=pow(x,5)+2*x+pow(x,-1);
    }
    else{
    y=sqrt(x);
    }
    printf("y=f(%f)=%.2f ",x,y);
    return 0;
    }

    二.心得

    我认为上课和作业并没有很大关系,即使上课没听懂 课后依然会做作业,因为种种原因,学习对我而言是一件很难的事情,仍需努力。

    三.预习

    下一次讲的内容是输出华氏-摄氏温度转换表

    1.如果要求输一张华氏-摄氏温度转换表,就要反复做多次温度转换计算和输出。

    在反复操作过程中,使用了同一个计算公式,但华氏温度的值每一次递增1F,因此计算出的摄氏温度也不同

    2.程序中用for语句实现循环。针对华氏温度在[lower,upper]内的每一个值,使用温度转换公式算出摄氏温度,并输出华氏温度和摄氏温度。温度的转换和输出是一个重复的操作,华氏温度每增加一次1F,直到超出给定的上限upper,循环结束。

    3.for语句

    在c语言中for语句被称为循环语句,它可以实现c语句的重复执行。

    四.自主学习

    花了半个小时,没怎么懂。

  • 相关阅读:
    [杂七杂八][高效程序员应该养成的七个习惯][转载]
    链表反转,只用两次头插法就实现了 hello
    清除空格 hello
    单词计数 hello
    单词查找程序 hello
    sdut 超级玛丽
    ural Episode Nth: The Jedi Tournament(缩点+建树)
    sudt 括号东东(模拟题)
    ural Pilot Work Experience(dfs + bfs )
    ural Team building(强连通分支)
  • 原文地址:https://www.cnblogs.com/liangjiajia/p/5898658.html
Copyright © 2011-2022 走看看