[ create a new paste ] login | about

Link: http://codepad.org/QnzkUMQ2    [ raw code | output | fork ]

C++, pasted on Dec 20:
import java.io.*;
import java.util.*;
public class Kadai629 {
	public static void main(String[] args) throws IOException {
		int ab_len = 3;
		AddressBook ab[] = new AddressBook[ab_len];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 0; i < ab_len; i++) {
			System.out.println(i + "人目");
			String s, f, k, m;
			System.out.print("氏名=");
			s = br.readLine();
			System.out.print("ふりがな=");
			f = br.readLine();
			System.out.print("携帯番号=");
			k = br.readLine();
			System.out.print("メールアドレス=");
			m = br.readLine();
			ab[i] = new AddressBook(s, f, k, m);
		}
		Arrays.sort(ab);
		show(ab);
		MailSort(ab);
		show(ab);
	}
	static void MailSort(AddressBook[] ab) {
		Arrays.sort(ab, new Comparator<AddressBook>() {
			@Override
			public int compare(AddressBook o1, AddressBook o2) {
				return o1.MAIL.compareTo(o2.MAIL);
			}

		});
	}
	static void show(AddressBook[] ab) {
		System.out.println("氏名\tふりがな\t携帯番号\tメールアドレス");
		for (int i = 0; i < ab.length; i++) {
			System.out.println(ab[i]);
		}
	}
}

class AddressBook implements Comparable<AddressBook> {
	String SHIMEI, FURIGANA, KEITAI, MAIL;
	public AddressBook(String shimei, String furigana, String keitai,
			String mail) {
		SHIMEI = shimei;
		FURIGANA = furigana;
		KEITAI = keitai;
		MAIL = mail;
	}
	@Override
	public int compareTo(AddressBook o) {
		return FURIGANA.compareTo(o.FURIGANA);
	}
	@Override
	public String toString() {
		return SHIMEI + "\t" + FURIGANA + "\t" + KEITAI + "\t" + MAIL;
	}

}


Output:
1
2
Line 28: error: stray '@' in program
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: