1 solutions

  • 0
    @ 2025-11-5 17:00:53

    C :

    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
    
        float a,b;
        scanf("%f",&a);
        if(a<=3)
            printf("8.00yuan");
        if(a>3)
        {
            b=8+(a-3)*1.6;
            printf("%.2fyuan",b);
        }
    
    }
    
    

    C++ :

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	double dist,fee;
    	cin>>dist;
    	if (dist<3.0) fee=8;
    	else fee=1.6*(dist-3)+8;
    	printf("%.2lfyuan\n",fee);
    	return 0;
    }
    

    Pascal :

    var
      n:extended;
      s:extended;
    begin
      readln(n);
      n:=n-3;
      s:=8+1.6*n;
      writeln(s:0:2,'yuan');
    end.
    
    • 1

    Information

    ID
    18149
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By