PAT Advanced Level 1011(Java and C++)
2014-09-01 22:42
375 查看
C++
Java
#include <iostream> #include <stdio.h> using namespace std; float maxF(float w ,float t ,float l){ if(w>= t && w>=l){ printf("W "); return w; } else if(t>= w && t>=l){ printf("T "); return t; } else{ printf("L "); return l; } } int main() { float w,t,l,profit =1; for(int i=0;i<3;i++){ scanf("%f%f%f",&w,&t,&l); profit *= maxF(w,t,l); } profit = (profit*0.65 -1)*2; printf("%.2f",profit); return 0 ; }
Java
import java.util.Scanner; public class Main { public static String toWord(int a){ if(a == 0){ return "W"; } else if(a==1){ return "T"; } else{ return "L"; } } public static void main(String[] arg){ Scanner sc = new Scanner(System.in); String[] arr1 =sc.nextLine().trim().split(" "); String[] arr2 =sc.nextLine().trim().split(" "); String[] arr3 =sc.nextLine().trim().split(" "); int maxInx1=0 , maxInx2 =0,maxInx3=0; double max1 =0 ,max2=0 ,max3=0; for(int i=0;i<3;i++){ double a1 ,a2 ,a3; a1 = Double.parseDouble(arr1[i]); a2 = Double.parseDouble(arr2[i]); a3 = Double.parseDouble(arr3[i]); if(a1>max1){ max1 = a1; maxInx1 =i; } if(a2>max2){ max2 = a2; maxInx2 =i; } if(a3>max3){ max3 = a3; maxInx3 =i; } } System.out.print(toWord(maxInx1)+" "); System.out.print(toWord(maxInx2)+" "); System.out.print(toWord(maxInx3)+" "); double result =(max1*max2*max3*0.65-1)*2; result =(double)Math.round(result*100)/100; System.out.println(result); } }
相关文章推荐
- PAT Advanced Level 1003. Emergency (25)(Java and C++)
- PAT Advanced Level 1035 (Java and C++)
- PAT Advanced Level 1018. Public Bike Management (30)(Java and C++)
- PAT Advanced Level 1043. Is It a Binary Search Tree (25)(Java and C++)
- Pat Advanced Level 1025(Java and C++)
- PAT Advanced Level 1030. Travel Plan (30)(Java and C++)
- PAT Advanced Level 1085. Perfect Sequence (25)(Java and C++)
- PAT Advanced Level 1086. Tree Traversals Again (25)(Java and C++)
- PAT Advanced Level 1002. A+B for Polynomials (25)(Java)
- PAT Advanced Level 1006:Sign In and Sign Out
- 【c++】PAT (Advanced Level) 1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1011-1020
- 【PAT Advanced Level】1011. World Cup Betting (20)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- PAT (Advanced Level) Practise 1011 World Cup Betting (20)
- 1011. World Cup Betting (20)——PAT (Advanced Level) Practise
- PAT Advanced Level 1036(Java)
- 【C++】PAT(advanced level)1056. Mice and Rice (25)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- 【c++】PAT (Advanced Level)1011. World Cup Betting (20)