Advertisement
evgenko

Untitled

Sep 3rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.25 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Main
  7. {
  8.     public static void CLEANER(char a[],int b){
  9.         for (int i=0;i<b;i++)
  10.             a[i]='\u0000';
  11.     }
  12.  
  13.     public static void main(String[] args) {
  14.         Scanner read = new Scanner(System.in);
  15.         String citycountry;
  16.         String cities[] = new String[10];
  17.         String countries[] = new String[10];
  18.         int number_city = 0;
  19.         int number_country = 0;
  20.         char name[] = new char[30];
  21.         boolean a = true;
  22.         String stop = "STOP";
  23.  
  24.         // READLINES
  25.         while (a) {
  26.             citycountry = read.next();
  27.             if ((citycountry).equals(stop))
  28.                 a = false;
  29.             if (a) {
  30.                 int i = 0;
  31.                 int b = 0;
  32.                 CLEANER(name,30);
  33.                 while (citycountry.charAt(i) != ',') {
  34.                     name[i] = citycountry.charAt(i);
  35.                     i++;
  36.                 }
  37.                 i++;
  38.                 cities[number_city] = String.valueOf(name);
  39.                 number_city++;
  40.                 System.out.println("OK");
  41.                 CLEANER(name,30);
  42.                 while (i < citycountry.length()) {
  43.                     name[b] = citycountry.charAt(i);
  44.                     i++;
  45.                     b++;
  46.                 }
  47.                 countries[number_country] = String.valueOf(name);
  48.                 number_country++;
  49.                 System.out.println("OK");
  50.  
  51.             }
  52.         }
  53.         a = true;
  54.  
  55.         //FINDCITY
  56.         while (a)
  57.         {
  58.             CLEANER(name,30);
  59.             citycountry = read.next();
  60.             for (int i=0; i< citycountry.length();i++)
  61.                 name[i] = citycountry.charAt(i);
  62.             citycountry = String.valueOf(name);
  63.  
  64.  
  65.             if ((citycountry).equals(stop))
  66.                 a = false;
  67.             for (int i=0; i<10;i++)
  68.             {
  69.                 if ((citycountry).equals(cities[i]))
  70.                     System.out.print(countries[i]);
  71.             }
  72.         }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.         /*for (int i = 0;i < 10; i++)
  79.         {
  80.             System.out.print(cities[i]);
  81.             System.out.print(" ");
  82.             System.out.println(countries[i]);
  83.         }*/
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement