解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class C1073 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int count = 0; while(sc.hasNext()){ String str = sc.nextLine(); if(str.indexOf("?") == -1){ //会做的情况 int indexOp = str.indexOf("+"); int indexEqual = str.indexOf("="); int rs = 0; if(indexOp != -1){ //加法题 rs = Integer.valueOf(str.substring(0, indexOp)) + Integer.valueOf(str.substring(indexOp+1, indexEqual)); }else{//减法题 indexOp = str.indexOf("-"); rs = Integer.valueOf(str.substring(0, indexOp)) - Integer.valueOf(str.substring(indexOp+1, indexEqual)); } int checkRs = Integer.valueOf(str.substring(str.indexOf("=")+1)); if(rs == checkRs) count++; } } System.out.println(count); sc.close(); } }
0.0分
6 人评分
计算质因子 (C++代码)浏览:1647 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:592 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:947 |
简单的a+b (C语言代码)浏览:600 |
用筛法求之N内的素数。 (C语言代码)浏览:812 |
简单的a+b (C语言代码)浏览:578 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:558 |
1126题解浏览:596 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:697 |
一元一次方程 (C语言代码)浏览:4070 |