fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. int n, a[];
  9. Scanner sc=new Scanner(System.in);
  10. n=sc.nextInt();
  11. a=new int[n];
  12. for(int i=0;i<n;i++){
  13. a[i]=sc.nextInt();
  14. }
  15. for(int i=0;i<n;i++){
  16. int tong=0;
  17. while(a[i]>0){
  18. tong=tong+a[i]%10;
  19. a[i]=a[i]/10;
  20. if(a[i]==0&&tong>=10){
  21. a[i]=tong;
  22. tong=0;
  23. }
  24. }
  25. System.out.println(tong);
  26. }
  27. }
  28. }
Runtime error #stdin #stdout #stderr 0.06s 4386816KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.util.Scanner.throwFor(Scanner.java:862)
	at java.util.Scanner.next(Scanner.java:1485)
	at java.util.Scanner.nextInt(Scanner.java:2117)
	at java.util.Scanner.nextInt(Scanner.java:2076)
	at Main.main(Main.java:10)