1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import java.util.Scanner; /** * UVA10008 */ public class UVA10008 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String temp = sc.nextLine(); temp = temp.replace(" ", ""); int num = Integer.parseInt(temp); int[] count = new int[26]; int max = 0; for (int i = 0; i < num; i++) { temp = sc.nextLine().toLowerCase(); for (int j = 0; j < temp.length(); j++) { if (temp.charAt(j) <= 122 && temp.charAt(j) >= 97) { count[temp.charAt(j) - 97]++; if (count[temp.charAt(j) - 97] > max) max = count[temp.charAt(j) - 97]; } } } for (int i = max; i > 0; i--) for (int j = 0; j < count.length; j++) { if (i == count[j]) System.out.println((char) (j + 65) + " " + count[j]); } sc.close(); } } |
Java – UVA490
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * UVA490 */ public class UVA490 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); List<String> input = new ArrayList<String>(); int max = 0; int maxLine = 0; while (sc.hasNextLine()) { String temp = sc.nextLine(); input.add(temp); if (max <= temp.length()) { max = temp.length(); maxLine = input.size() - 1; } } for (int i = 0; i < max; i++) { for (int j = input.size() - 1; j >= 0; j--) { String temp = input.get(j); if (temp.length() > i) System.out.print(temp.charAt(i)); else if (j > maxLine) System.out.print(" "); } System.out.println(); } sc.close(); } } |
Java – UVA272
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import java.util.Scanner; /** * UVA272 */ public class UVA272 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); boolean symbol = false; while (sc.hasNextLine()) { String temp = sc.nextLine(); for (int i = 0; i < temp.length(); i++) { if (temp.charAt(i) == '\"') { if (!symbol) System.out.print("<code></code>"); else System.out.print("\'\'"); symbol = !symbol; } else System.out.print(temp.charAt(i)); } System.out.println(); } sc.close(); } } |
Java 2018-04-18 HW
檔案下載
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
/** * CDogKind */ class CDogKind { String Kind, Name; int age; void show() { System.out.println("寵物種類:" + Kind); } } /** * CDog */ class CDog extends CDogKind { CDog(String Kind, String Name, int age) { this.Kind = Kind; this.Name = Name; this.age = age; } void setAge(int age) { this.age = age; } void setName(String Name) { this.Name = Name; } void show() { super.show(); System.out.println("寵物名子:" + this.Name); System.out.println("寵物年齡:" + this.age); } } /** * Java_2018_04_18_HW * Author:Dragonyue */ public class Java_2018_04_18_HW { public static void main(String[] args) { CDog myDog = new CDog("柯基", "小昌弟弟", 3); myDog.show(); } } |
C++ HW10.4 For WallPower
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
//檔案名稱:d:\VC++10\VC1010.cpp #include <iostream> #include <iomanip> //插入設定格式標題檔 using namespace std; struct Booklist //宣告Booklist資料結構 { char title[25]; //Booklist第1成員變數 char auther[9]; //Booklist第2成員變數 char number[11]; //Booklist第3成員變數 float price; //Booklist第4成員變數 }; void getBook(Booklist *); //宣告getBook函數原型 void showBook(Booklist *); //宣告showBook函數原型 int main(int argc, char *argv[]) { Booklist book[2]; //建立Booklist型態陣列 for (int i = 0; i < 2; i++) //輸入Booklist資料迴圈 { getBook(&book[i]); //book[i]=輸入結構資料 cin.ignore(); //忽略最後一個輸入字元 } cout << "書名\t\t\t作者\t\t書號\t\t定價\n"; showBook(book); //傳遞結構陣列給showBook函數 system("PAUSE"); return EXIT_SUCCESS; } void getBook(Booklist *bl) //輸入圖書資料函數 { cout << "請輸入書名:"; cin.getline(bl->title, 24); //輸入第1成員資料 cout << "請輸入作者:"; cin.getline(bl->auther, 8); //輸入第2成員資料 cout << "請輸入書號:"; cin.getline(bl->number, 10); //輸入第3成員資料 cout << "請輸入定價:"; cin >> bl->price; //輸入第4成員資料 cout << endl; } void showBook(Booklist *b) //輸出圖書資料函數 { cout.precision(2); //設定數值的有效位數 cout.setf(ios::fixed | ios::left); //固定小數2位數,向左對齊 for (int j = 0; j < 2; j++) //輸出圖書資料迴圈 { cout << setw(24) << (b + j)->title; //輸出b第1成員資料 cout << setw(16) << (b + j)->auther; //輸出b第2成員資料 cout << setw(16) << (b + j)->number; //輸出b第3成員資料 cout << (b + j)->price << '\n'; //輸出b第4成員資料*/ } } |
Java 2018-04-11 HW2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import java.util.Scanner; /** * Java_2018_04_11_HW2 * Author:Dragonyue */ public class Java_2018_04_11_HW2 { public static void main(String[] args) { // TODO 自動產生的方法 Stub Scanner scanner = new Scanner(System.in); System.out.print("輸入:"); int num = Integer.parseInt(scanner.nextLine()); for (int i = 0; i < num; i++) { for (int j = 0; j <= i; j++) { System.out.print(PSC(i, j) + " "); } System.out.println(); } } public static int PSC(int r, int c) { if (r == c || c == 0) return 1; else return PSC(r - 1, c) + PSC(r - 1, c - 1); } } |
Jav 2018-04-11 HW1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import java.util.Scanner; /** * Java_2018_04_11_HW1 * Author:Dragonyue */ class A { int SN; String Name; A() { System.out.println("111"); } A(int SN) { this(); System.out.println("222"); this.SN = SN; } void setName(String Name) { this.Name = Name; } String getName() { return this.SN + "\r\n" + this.Name; } void A(String str) { System.out.print("1個" + str); } void A(String num, String str) { int n = Integer.parseInt(num); System.out.print(num + "個" + str); } } public class Java_2018_04_11_HW1 { public static void main(String[] args) { A aA = new A(333); aA.setName("Howhow"); System.out.println(aA.getName()); Scanner scanner = new Scanner(System.in); String[] str = scanner.nextLine().split(" "); if (str.length == 1) aA.A(str[0]); else if (str.length == 2) aA.A(str[0], str[1]); } } |
C++ HW5 for Chunk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <iostream> #include <iomanip> using namespace std; int main() { int month, first, total, newline = 6; cout << "輸入月份:"; cin >> month; cout << "輸入" << month << "月1日是星期幾:"; cin >> first; cout << "輸入" << month << "月總天數:"; cin >> total; cout << setw(10) << "2018年" << month << "月" << endl; cout << setw(3) << "日" << setw(3) << "一" << setw(3) << "二" << setw(3) << "三" << setw(3) << "四" << setw(3) << "五" << setw(3) << "六" << endl; for (int i = 0; i < first; i++) cout << setw(3) << " "; for (int i = first; i < total + first; i++) { cout << setw(3) << i - first + 1; if (i == newline) { cout << endl; newline += 7; } } cout << endl; system("pause"); return 0; } |