Advertisement
476179

Untitled

Mar 12th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3. public class FreeShirts
  4. {
  5. public static void main(String[] args) throws IOException //throw-n provides exception if file not found
  6. {
  7. int wash = 0;
  8. //open file for reading, must create file object first
  9. File file = new File("C:\\Users\\mitcpale842\\Desktop\\ECOO_fileReading\\DATA11.txt");
  10. // on windows must use two backslashes
  11.  
  12. Scanner inputFile = new Scanner(file);
  13. int b=0,a=0,v=0;
  14. while (inputFile.hasNext())
  15. {
  16.  
  17. int n = inputFile.nextInt();
  18. int m = inputFile.nextInt();
  19. int d = inputFile.nextInt();
  20.  
  21. inputFile.nextLine();
  22. String sentence = inputFile.nextLine();
  23. String[] a1 = sentence.split(" ");
  24.  
  25. int D = 0;
  26. int N =0;
  27. // int wash = 0;
  28. for(int i = 1; i <= D; i++)
  29. {
  30. N--;
  31. for(int x = 0; x < a1.length; x++)
  32. { if(i== Integer.parseInt(a1[x]))
  33. { N++;
  34. }
  35. }
  36. }
  37. if(N == 0)
  38. {
  39. wash++;
  40. N = n;
  41. }
  42. }
  43.  
  44. System.out.println(wash);
  45.  
  46. inputFile.close();
  47.  
  48. }
  49.  
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement