1001. A+B Format (20)---------------PAT开始
生活随笔
收集整理的這篇文章主要介紹了
1001. A+B Format (20)---------------PAT开始
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
今天是第一次用Java提交PAT的代碼:
源代碼不能直接提交,需要經過修改:
源代碼:
1 package test;//提交時不能顯示這句 2 3 import java.util.Scanner; 4 5 public class Test_1001 {//提交時名字要改成Main 6 public static void main(String[] args) { 7 Scanner inScanner =new Scanner(System.in); 8 long a=inScanner.nextLong(); 9 long b=inScanner.nextLong(); 10 long c=a+b; 11 if(c<0){ 12 System.out.print("-"); 13 c=0-c; 14 } 15 String s=String.valueOf(c); 16 String out=""; 17 int count=0; 18 for(int i=s.length()-1;i>=0;i--){ 19 out=s.charAt(i)+out; 20 count++; 21 if(count%3==0&&i!=0){ 22 count=0; 23 out=","+out; 24 } 25 26 } 27 System.out.println(out); 28 } 29 30 }?
轉載于:https://www.cnblogs.com/jianrenguo/p/6818236.html
總結
以上是生活随笔為你收集整理的1001. A+B Format (20)---------------PAT开始的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 盛京银行信用卡额度多少?怎么提额?
- 下一篇: Date扩展 正则匹配