Created
May 17, 2014 09:00
-
-
Save codegagan/c93b13f5de37d410ab26 to your computer and use it in GitHub Desktop.
Some problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Enter the input as commandline arguments | |
public class Problem_B{ | |
public static void main(String args[]){ | |
//System.out.println("Positive Sum"); | |
//if(args[0]=='')System.out.println("Please Enter Commandline Arguments"); | |
if(args[0].charAt(0)=='-')System.out.println("Enter Positive No. of Test Cases"); | |
int Test_Cases=Integer.parseInt(args[0].substring(0,1)); | |
//System.out.println(args[0].substring(0,1)); | |
int T[]=new int[Test_Cases]; | |
if(args[0].charAt(1)=='-' || args[0].charAt(2)=='-')System.out.println("Enter Positive count of numbers in 1st Test Case"); | |
T[0]=Integer.parseInt(args[0].substring(1,2)); | |
for(int k=1;k<Test_Cases;k++){ | |
if(args[k].charAt(0)=='-')continue; | |
T[k]=Integer.parseInt(args[k].substring(0,1)); | |
} | |
int A[][]=new int[Test_Cases][]; | |
for(int i=0;i<Test_Cases;i++){ | |
A[i]=new int[T[i]]; | |
} | |
for(int j=0;j<T[0];j++){ | |
A[0][j]=Integer.parseInt(args[0].substring(j+2,j+3)); | |
} | |
for(int l=0;l<Test_Cases;l++){ | |
for(int m=0;m<T[l];m++){ | |
A[l][m]=Integer.parseInt(args[l].substring(m,m+1)); | |
} | |
} | |
//calculating sum | |
int sum[]=new int[Test_Cases]; | |
for(int p=0;p<sum.length;p++){sum[p]=0;} | |
for(int n=0;n<Test_Cases;n++){ | |
for(int o=0;o<A[n].length;o++){ | |
if(A[n][o]>=0) | |
{sum[n]+=A[n][o];} | |
} | |
} | |
/*printing array | |
for(int n=0;n<Test_Cases;n++){ | |
for(int o=0;o<A[n].length;o++){ | |
System.out.println(A[n][o]);} | |
} | |
*/ | |
//printing final | |
for(int q=0;q<sum.length;q++){System.out.println(sum[q]);} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment