1 条题解

  • 0
    @ 2025-4-7 21:29:26

    C :

    #include <stdio.h>
    int main()
    {
    	int t,profit;
    	scanf("%d",&t);
    	if(t<=160)
    	{
    		profit=10*t;
    	}
    	if(t>160)
    	{
    		profit=1600+(t-160)*10*3;
    	}
    	printf("%d\n",profit);
    	return 0;	
    }
    

    C++ :

    #include<iostream>
    using namespace std;
    int main()
    {
    	int t,fee;
    	cin>>t;
    	if (t<=160) fee=10*t;
    	else fee=160*10+(t-160)*30;
    	cout<<fee<<endl;
    	return 0;
    }
    

    Java :

    
    import java.util.Scanner;
    
    public class Main {
    	public static void main(String[] args) {
    		Scanner cin=new Scanner(System.in);
    		int man_hour=cin.nextInt();
    		Employee employee=new Employee();
    		employee.setMan_hour(man_hour);
    		System.out.println(employee.ComputeIncome());
    	}
    }
    
    class Employee{
    	int hourly;//时薪
    	int man_hour;//工时
    	int income;
    	public Employee() {
    		hourly=10;
    		man_hour=0;
    		income=0;
    	}
    	public void setMan_hour(int man_hour) {
    		this.man_hour = man_hour;
    	}
    	public int ComputeIncome(){
    		income=0;
    		if (man_hour<=160)
    		{
    			income=man_hour*hourly;
    		}
    		else{
    			income=160*hourly+(man_hour-160)*hourly*3;
    		}
    		return income;
    	}
    }
    
    • 1

    《C语言程序设计》江宝钏主编-习题4-4-加班费

    信息

    ID
    1469
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者