L1-017 到底有多二 (15 分) java解题
2024-09-01 12:59:30
1 import java.util.Scanner;
2
3 public class Main {
4 public static void main(String args[]){
5 double sum=0;
6 double bei=1;
7 int len;
8 int count=0;
9 String str=null;
10 Scanner in=new Scanner(System.in);
11 str=in.next();
12 len=str.length();
13 if (str.charAt(0)=='-'){
14 len=str.length()-1;
15 bei=1.5;
16 }
17 for (int i=0;i<str.length();i++){
18 if (str.charAt(i)=='2'){
19 count++;
20 }
21 }
22 int bei2=1;
23 if (Integer.parseInt(str.charAt(str.length()-1)+"")%2==0){
24 bei2=2;
25 }
26 sum=((double) count/len)*bei*bei2*100;
27 System.out.printf("%.2f%s",sum,"%");
28 }
29 }
最新文章
- CentOS安装gitLab服务器
- TensorFlow知识总结
- 将Controller抛出的异常转到特定View
- web-api-global-error-handling
- meteor icons &; splash配置
- 科学家有了钱以后,真是挺吓人的——D.E.Shaw的牛逼人生
- 你尽力了么===BY cloudsky
- SpringNote02.Blog系统迁移到Linux下
- #include <;boost/regex.hpp>;
- LINUX RHEL6.5字符界面安装图形化桌面
- Day2-字符编码转换
- .Net程序员学用Oracle系列(29):PLSQL 之批量应用和系统包
- EasyUI 冻结列
- (60)Wangdao.com第十天_JavaScript 函数_作用域_闭包_IIFE_回调函数_eval
- webpack学习笔记(五)
- Windows服务器
- 通过ALT+F9关键CALL追踪注册码
- 第一个python程序--hello,world
- MyBatis #{} 取值注意事项
- .NetCore WebApi利用Swagger文档实现选择文件上传
热门文章
- unexpected end of file while looking for precompiled header. Did you forget to add &#39;#include ";stdafx.h";&#39; to your source 解决办法
- Java基础(三)——内部类
- Python - 进度条库 tqdm
- JetBrains 系列软件汉化包 2017.3-2018.1
- uni-app开发基本知识点
- PHP方法参数的那点事儿
- C博客作业00--顺序分支结构
- Java基础系列(12)- 运算符
- SourceTree使用详解-摘录收藏
- Jmeter系类(32) - JSR223(2) | Groovy常见内置函数及调用