java从假设有10道题,做对一题得10分,做错一题扣3分,某同学答完10道题得74分,问该同学答对、答错多少题?
4个回答
2010-09-28
展开全部
public class xx {
public static void main(String args[]) {
int score = 74;
int t = 10;
int f = -3;
for (int i = 0; i <=10; i++) {
for (int j = 1; j < i; j++) {
if(score==t*i+f*j){
System.out.println("对"+i+"错"+j);
break;
}else{
continue;
}
}
}
}
}
public static void main(String args[]) {
int score = 74;
int t = 10;
int f = -3;
for (int i = 0; i <=10; i++) {
for (int j = 1; j < i; j++) {
if(score==t*i+f*j){
System.out.println("对"+i+"错"+j);
break;
}else{
continue;
}
}
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
x*10-(10-x)*3=74
x=8
x=8
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class DoWork {
public static void main(String[] ar) {
int right = 10;
int wrong = -3;
for(int rightI = 01; rightI < 11; rightI++) {
for(int wrongI = 1; wrongI < 11; wrongI++) {
if(right * rightI + wrong * wrongI == 74) {
System.out.println("right: " + rightI + " wrong: " + wrongI);
return;
}
}
}
}
}
public static void main(String[] ar) {
int right = 10;
int wrong = -3;
for(int rightI = 01; rightI < 11; rightI++) {
for(int wrongI = 1; wrongI < 11; wrongI++) {
if(right * rightI + wrong * wrongI == 74) {
System.out.println("right: " + rightI + " wrong: " + wrongI);
return;
}
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询