Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class FreeShirts
- {
- public static void main(String[] args) throws IOException //throw-n provides exception if file not found
- {
- int wash = 0;
- //open file for reading, must create file object first
- File file = new File("C:\\Users\\mitcpale842\\Desktop\\ECOO_fileReading\\DATA11.txt");
- // on windows must use two backslashes
- Scanner inputFile = new Scanner(file);
- int b=0,a=0,v=0;
- while (inputFile.hasNext())
- {
- int n = inputFile.nextInt();
- int m = inputFile.nextInt();
- int d = inputFile.nextInt();
- inputFile.nextLine();
- String sentence = inputFile.nextLine();
- String[] a1 = sentence.split(" ");
- int D = 0;
- int N =0;
- // int wash = 0;
- for(int i = 1; i <= D; i++)
- {
- N--;
- for(int x = 0; x < a1.length; x++)
- { if(i== Integer.parseInt(a1[x]))
- { N++;
- }
- }
- }
- if(N == 0)
- {
- wash++;
- N = n;
- }
- }
- System.out.println(wash);
- inputFile.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement