PAT Advanced Level 1011(Java and C++)
来源:互联网 发布:网络平台 英文缩写 编辑:程序博客网 时间:2024/06/05 06:16
C++
#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);}}
0 0
- PAT Advanced Level 1011(Java and C++)
- Pat Advanced Level 1025(Java and C++)
- PAT Advanced Level 1035 (Java and C++)
- PAT Advanced Level 1085. Perfect Sequence (25)(Java and C++)
- PAT Advanced Level 1003. Emergency (25)(Java and C++)
- PAT Advanced Level 1030. Travel Plan (30)(Java and C++)
- PAT Advanced Level 1018. Public Bike Management (30)(Java and C++)
- PAT Advanced Level 1086. Tree Traversals Again (25)(Java and C++)
- PAT Advanced Level 1043. Is It a Binary Search Tree (25)(Java and C++)
- 【C++】PAT(advanced level)1056. Mice and Rice (25)
- 【C++】PAT (advanced level)1062. Talent and Virtue (25)
- PAT Advanced Level 1036(Java)
- PAT-PAT (Advanced Level) Practise A+B and C (64bit) (20) 【二星级】
- 【C++】PAT(advanced level)1046. Shortest Distance (20)
- PAT Advanced Level 1020. Tree Traversals (25)(Java 实现)
- 【c++】PAT (Advanced Level)1008. Elevator (20)
- 【c++】PAT (Advanced Level)1010. Radix (25)
- 【c++】PAT (Advanced Level)1035. Password (20)
- 的会不会发现和细节和副研究员发现静一静
- test
- Weka算法Classifier-tree-J48源码分析(一)算法和基本数据结构
- 《大学算法教程Algorithms》笔记--Chapter1--Part3
- ubuntu AMD显卡驱动安装
- PAT Advanced Level 1011(Java and C++)
- Protel 封装库转PADS格式方法
- SQL Server表误删记录恢复的方法
- acm steps (Fibonacci)
- Maximum Depth of Binary Tree
- matlab IIr C语言实现
- Oracle Type介绍
- 生活记录:从今天开始记录每天的学习和进步
- Map中根据value值的大小进行排序