|
|
вернуться в форумWhy crash is happening Послано Paul 6 ноя 2012 20:36 this is my code and its wrking fine on my pc import java.io.*; import java.util.Scanner; public class Democracy { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub
Scanner sc = new Scanner (System.in); System.out.println("enter no of groups"); int n = sc.nextInt();
System.out.println("enter group members"); //String s = sc.next(); //String[] num = s.split(","); String[] num = sc.next().split(",");
int[] num1 = new int[num.length]; int x =0; for(String a: num){ num1[x] = Integer.parseInt(a); //System.out.println(a); x++; }
int len = n/2+1; int[] min = new int[len];
for(int i = 0; i <len; i++ ){ min[i] = num1[i]; for(int j= i+1; j<num1.length; j++ ){ if(min[i] > num1[j]){ min[i] = num1[j]; } } }
int vote = 0; for(int i =0; i<len; i++){ vote = vote+ min[i]/2+1; }
System.out.println(vote);
} } |
|
|