ผลต่างระหว่างรุ่นของ "418383/418587 ภาคปลาย 2553/คะแนนการบ้าน 1"
ไปยังการนำทาง
ไปยังการค้นหา
Cardcaptor (คุย | มีส่วนร่วม) (หน้าที่ถูกสร้างด้วย '== การลอกกันที่ผมจับได้ == === โค้ดอ่านไฟล์ใน PlayScreen.cs === <table…') |
Cardcaptor (คุย | มีส่วนร่วม) |
||
แถว 5: | แถว 5: | ||
<td align="center">'''51180537'''</td> | <td align="center">'''51180537'''</td> | ||
<td align="center">'''51180628'''</td> | <td align="center">'''51180628'''</td> | ||
+ | <td align="center">'''51180644'''</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
แถว 68: | แถว 69: | ||
for (i = 0; i < 10; i++) | for (i = 0; i < 10; i++) | ||
writer.WriteLine(s2[i]); | writer.WriteLine(s2[i]); | ||
+ | writer.Close(); | ||
+ | </geshi> | ||
+ | </td> | ||
+ | <td> | ||
+ | <geshi lang="C#"> | ||
+ | int[] score2 = new int[10] ; | ||
+ | lvcount = 1000; | ||
+ | lvup = 1; | ||
+ | var write = new StreamWriter("last.txt"); | ||
+ | |||
+ | write.WriteLine(score); | ||
+ | write.Close(); | ||
+ | StreamReader sr = new StreamReader("data.txt"); | ||
+ | int i = 0; | ||
+ | string str; | ||
+ | while ((str = sr.ReadLine()) != null) | ||
+ | { | ||
+ | score2[i] = int.Parse(str) ; | ||
+ | |||
+ | i++; | ||
+ | } | ||
+ | |||
+ | sr.Close(); | ||
+ | |||
+ | |||
+ | for (i = 0; i < 10; i++) | ||
+ | { | ||
+ | |||
+ | |||
+ | if (score>=score2[i]) | ||
+ | { | ||
+ | for (int j = 10 - 1; j > i; j--) | ||
+ | score2[j] = score2[j - 1]; | ||
+ | score2[i] = score; | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | var writer = new StreamWriter("data.txt"); | ||
+ | for (i = 0; i < 10; i++) | ||
+ | writer.WriteLine(score2[i]); | ||
writer.Close(); | writer.Close(); | ||
</geshi> | </geshi> |
รุ่นแก้ไขเมื่อ 19:46, 27 กุมภาพันธ์ 2554
การลอกกันที่ผมจับได้
โค้ดอ่านไฟล์ใน PlayScreen.cs
51180537 | 51180628 | 51180644 |
<geshi lang="C#"> string[] score2 = new string[10]; StreamReader sr = new StreamReader("Score.txt"); int i = 0; string str; while ((str = sr.ReadLine()) != null) { score2[i] = str; i++; } sr.Close();
for (i = 0; i < 10; i++) {
if (scoreNumLabel.Text.CompareTo(score2[i]) > 0) { for (int j = 10 - 1; j > i; j--) score2[j] = score2[j - 1]; score2[i] = scoreNumLabel.Text; break; } } var writer = new StreamWriter("Score.txt"); for (i = 0; i < 10; i++) writer.WriteLine(score2[i]); writer.Close(); </geshi> |
<geshi lang="C#"> string[] s2 = new string[10]; StreamReader sr = new StreamReader("lvscore.txt"); int i = 0; string str; while ((str = sr.ReadLine()) != null) { s2[i] = str; i++; } sr.Close(); for (i = 0; i < 10; i++) { if (scoreNumLabel.Text.CompareTo(s2[i]) > 0) { for (int j = 10 - 1; j > i; j--) s2[j] = s2[j - 1]; s2[i] = scoreNumLabel.Text; break; } } var writer = new StreamWriter("lvscore.txt"); for (i = 0; i < 10; i++) writer.WriteLine(s2[i]); writer.Close(); </geshi> |
<geshi lang="C#"> int[] score2 = new int[10] ; lvcount = 1000; lvup = 1; var write = new StreamWriter("last.txt"); write.WriteLine(score); write.Close(); StreamReader sr = new StreamReader("data.txt"); int i = 0; string str; while ((str = sr.ReadLine()) != null) { score2[i] = int.Parse(str) ; i++; } sr.Close(); for (i = 0; i < 10; i++) { if (score>=score2[i]) { for (int j = 10 - 1; j > i; j--) score2[j] = score2[j - 1]; score2[i] = score; break; } } var writer = new StreamWriter("data.txt"); for (i = 0; i < 10; i++) writer.WriteLine(score2[i]); writer.Close(); </geshi> |