Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main
- {
- public static void CLEANER(char a[],int b){
- for (int i=0;i<b;i++)
- a[i]='\u0000';
- }
- public static void main(String[] args) {
- Scanner read = new Scanner(System.in);
- String citycountry;
- String cities[] = new String[10];
- String countries[] = new String[10];
- int number_city = 0;
- int number_country = 0;
- char name[] = new char[30];
- boolean a = true;
- String stop = "STOP";
- // READLINES
- while (a) {
- citycountry = read.next();
- if ((citycountry).equals(stop))
- a = false;
- if (a) {
- int i = 0;
- int b = 0;
- CLEANER(name,30);
- while (citycountry.charAt(i) != ',') {
- name[i] = citycountry.charAt(i);
- i++;
- }
- i++;
- cities[number_city] = String.valueOf(name);
- number_city++;
- System.out.println("OK");
- CLEANER(name,30);
- while (i < citycountry.length()) {
- name[b] = citycountry.charAt(i);
- i++;
- b++;
- }
- countries[number_country] = String.valueOf(name);
- number_country++;
- System.out.println("OK");
- }
- }
- a = true;
- //FINDCITY
- while (a)
- {
- CLEANER(name,30);
- citycountry = read.next();
- for (int i=0; i< citycountry.length();i++)
- name[i] = citycountry.charAt(i);
- citycountry = String.valueOf(name);
- if ((citycountry).equals(stop))
- a = false;
- for (int i=0; i<10;i++)
- {
- if ((citycountry).equals(cities[i]))
- System.out.print(countries[i]);
- }
- }
- /*for (int i = 0;i < 10; i++)
- {
- System.out.print(cities[i]);
- System.out.print(" ");
- System.out.println(countries[i]);
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement