您的位置:首页 > 编程语言

网易2018校招在线编程题-第一题

2017-08-12 17:30 316 查看
package com.neitui.demo1;

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();//房租
int b = sc.nextInt();//已有的水果个数
int c = sc.nextInt();//已有的钱数
int d = sc.nextInt();//每个水果p元
int count = 0;
//先解决异常情况
if(b > c/a){
count = c/a;
}else{
count = b;
}
c = c - count*a;
b = b -	count;
while(c>0){
c=c-a-d;
if(c<0){
break;
}
count++;
}
System.out.println(count);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: