Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- public class Main {
- public static void main(String[] args) {
- try {
- double ar[]= new double[10];
- int thesh[]=new int[10];
- Scanner input=new Scanner(new File("C:/software/practise/src/hydrocarbons.in"));
- int oik =input.nextInt();
- int pl =-1;
- int j =-1;
- double t =0;
- while (input.hasNext())
- {
- int a=input.nextInt();
- int b=input.nextInt();
- int c=input.nextInt();
- t=a-a*(b/3000)-c*a/40;
- j++;
- if(t>0)
- {
- pl++;
- ar[pl]=t;
- thesh[pl]=j+1;
- }
- }
- boolean f=true;
- //System.out.println(Arrays.toString(ar));
- //System.out.println(Arrays.toString(thesh));
- System.out.print(pl);
- int k =1;
- int temp=0;
- double temp2=0;
- while (k<=pl & f==true) {
- f=false;
- for (int i = pl-1; pl-1 >=k; i--)
- {
- if(ar[i]>ar[i-1] || (ar[i]==ar[i-1] & thesh[i]<thesh[i-1]))
- {
- f=true;
- System.out.print(f);
- temp2=ar[i];
- ar[i]=ar[i-1];
- ar[i-1]=temp2;
- temp=thesh[i];
- thesh[i]=thesh[i-1];
- thesh[i-1]=temp;
- System.out.println(Arrays.toString(ar));
- System.out.println(Arrays.toString(thesh));
- System.out.print(k);
- }
- }
- k++;
- }
- System.out.println(Arrays.toString(ar));
- System.out.println(Arrays.toString(thesh));
- try
- {
- File file = new File("C:/software/practise/src/hydrocarbons.out");
- FileWriter fw = new FileWriter(file);
- PrintWriter pw = new PrintWriter(fw);
- pw.println(pl);
- for(int i=0; i<=pl;i++)
- {
- System.out.println(Arrays.toString(thesh));
- pw.println(thesh[i]);
- }
- pw.close();
- }
- catch (Exception ex){}
- input.close();
- }
- catch (Exception ex){}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement