输入包括一行,一行中有三个正整数n, t, a(1 ≤ n, t, a ≤ 50), 以空格分割
输出一个整数,表示牛牛可能获得的最高分是多少。
3 1 2
2
#include<iostream>
using namespace std;
int main()
{
int a,n,t;
cin>>n>>t>>a;
cout<<((t>a)?(a+n-t):(t+n-a))<<endl;
return 0;
}
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner cin=new Scanner (System.in);
int n=cin.nextInt();//总题目数
int t=cin.nextInt();//在考试中牛牛选择√的题目数
int a=cin.nextInt();//n道题目中√的题目数
int max=0;
if(t<=a) {
max=max+t+n-a;
}
else {
max=max+a+n-t;
}
System.out.print(max);
}
}
分三种情况:t=a时,这时的最高分数就是蒙的全部都对;Maxscore=n; t>a时,要保证分数最高也只是蒙的全部都对,对应蒙‘错’的也对 Maxscore=a+n-t; t<a时,要想获得的分数最高蒙的全部都对。Maxscore=t+n-a;#include<iostream> using namespace std; int main() { int a, t, n; int Maxscore=0; cin >> n >> t >> a; if (t == a) Maxscore = n; else if (t > a) Maxscore = a + n - t; else Maxscore = t + n - a; cout << Maxscore << endl; return 0; }
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int t = sc.nextInt(); //牛牛的正确
int a= sc.nextInt(); //实际上的正确
int noNiu = n - t; //牛牛的错误
int noRel = n - a; //实际上的错误
int sum = 0;
if (t > a) {
sum += a;
} else {
sum += t;
}
if (noNiu > noRel) {
sum += noRel;
} else {
sum += noNiu;
}
System.out.println(sum);
}
}
#include<iostream>
using namespace std;
int main() {
int n, t, a;
cin >> n >> t >> a;
if (t == a) {
cout << n << endl;
} else if (t < a) {
int wrong = n - a;
int welldone = wrong + t;
cout << welldone <<endl;
} else {
int wrong = n - a;
wrong = wrong - (t - a);
int welldone = wrong + a;
cout << welldone << endl;
}
return 0;
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author wylu
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] strs = br.readLine().split(" ");
int n = Integer.parseInt(strs[0]), t = Integer.parseInt(strs[1]), a = Integer.parseInt(strs[2]);
System.out.println(Math.min(t, a) + Math.min(n - t, n - a));
}
}
#include<iostream>
using namespace std;
int main(){
int n,t,a;
cin>>n>>t>>a;
if(t>a)
cout<<n-(t-a)<<endl;
else
cout<<n-(a-t)<<endl;
}