Author : Jisan
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-10327
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1268
Code:
import java.util.*;
public class Uva_10327 {
public static void main(String args[]){
Scanner input=new Scanner(System.in);
while(input.hasNext()){
int a=input.nextInt();
int[] tomato=new int[a];
for(int b=0;b<tomato.length;b++){
tomato[b]=input.nextInt();
}
int count=flipSort(tomato);
System.out.println("Minimum exchange operations : "+ count);
}
}
public static int flipSort(int[] A){
int s=0;
for(int i=0;i<A.length-1;i++){
for(int j=i+1;j<A.length;j++){
if(A[i]>A[j]){
s++;
}
}
}
return s;
}
}
Programming language : Java
Difficulty : Easy
Status : Accepted
Problem number : UVA-10327
http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1268
Code:
import java.util.*;
public class Uva_10327 {
public static void main(String args[]){
Scanner input=new Scanner(System.in);
while(input.hasNext()){
int a=input.nextInt();
int[] tomato=new int[a];
for(int b=0;b<tomato.length;b++){
tomato[b]=input.nextInt();
}
int count=flipSort(tomato);
System.out.println("Minimum exchange operations : "+ count);
}
}
public static int flipSort(int[] A){
int s=0;
for(int i=0;i<A.length-1;i++){
for(int j=i+1;j<A.length;j++){
if(A[i]>A[j]){
s++;
}
}
}
return s;
}
}
No comments:
Post a Comment