• 第四次修改


    总结:

    做作业写程序时,要先把思路和框图想清楚和构造好。然后根据思路和程序框图写程序。最重要是熟悉和清楚C语言教材上的基本内容。最后检查语法错误。

    本次作业学习要点为if else语句的应用。

    /*起步三公里。10元。起步路程后10里,每里2元。起步路程后10里后部分,3元每里。路阻及要求停车,每5分钟2元。行驶里程s  等待时间t  所需付费w  */
    
    #include<stdio.h>
    #include<stdlib.h>
    int main(void)
    {
        int s,t,w;
    
        printf("输入s,t");
        scanf("%d%d",&s,&t);
        if(s<3 && t<5){
            w=10;
        printf("w=%d
    ",w);
        return 0;}
    
        else if(s>3 && s<13 && t<5){
            w=10+2*(s-3);
        printf("w=%d
    ",w);
        return 0;}
            
        else if(s>13 && t<5){
            w=10+(2*10)+3*(s-13);
        printf("w=%d
    ",w);
        return 0;}
    
    
        if(s<3 && t>5){
            w=10+2*int(t/5);
        printf("w=%d
    ",w);
        return 0;}
    
        else if(s>3 && s<13 && t>5){
            w=10+2*(s-3)+2*int(t/5);
        printf("w=%d
    ",w);
        return 0;}
            
        else if(s>13 && t>5){
            w=10+(2*10)+3*(s-13)+2*int(t/5);
        printf("w=%d
    ",w);
        return 0;}
    
        return 0;
    }
    }

    /*输入任意三个坐标,输出周长及面积,否则输出 “impossible”*/
    
    
    #include<stdio.h>
    #include<math.h>
     main(void)
    {
    double x1,x2,x3,y1,y2,y3,L1,L2,L3,c,s,m;
    printf("请输入一组数据:");
    scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
    L1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    L2=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
    L3=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    printf(" L1=%.2lf
     L2=%.2lf
     L3=%.2lf
    ",L1,L2,L3);
    
     
     if((L1+L2>L3) && (L1+L3>L2) && (L2+L3>L1)){
    
         c=L1+L2+L3;
         m=c/2;
         s=sqrt(m*(m-L1)*(m-L2)*(m-L3));
     printf(" c=%.2f
     s=%.2f
    ",c,s);
     return 0;}
     else{
    
          printf("Impossible
    ");
          return 0;}
     return 0;
    }
  • 相关阅读:
    尝试消除switch
    JsUnit的测试套件
    GetCallbackEventReference对我来说太复杂了
    实现获取客户端的MAC地址(2)
    控件开发复习
    在VS2008的JScript编辑器中显示为命名空间
    函数参数修饰符out、ref及空白的区别
    检测代码位置的比较(C#代码VS存贮过程)
    发布时,正在使用的用户出错
    js特效,加速度,图标跳动
  • 原文地址:https://www.cnblogs.com/yixiaoxia/p/10682985.html
Copyright © 2020-2023  润新知