You are on page 1of 51

ชื่อ-นามสกุล รหัสนักศึกษา Section

8 จงหาผลการทำางานของโปรแกรมต่อไปนี้
8.1 (5 คะแนน)
#include <iostream.h>
main() {
int a[3][4] = {{ 1,2,3,4}, {5,6,7,8},{9,10,11,12}};
int k = 1, m = 2;
a[0][0] = 0;
a[k][m] = 0;
a[k+1][m+1] = a[k-1][m-1];
for(int i = 0; i < 3; i++) {
for (int j =0; j < 4; j++) {
cout << a[i][j] << " ";
}
cout << endl;
}
}

8.2 (5 คะแนน)
#include <iostream.h>

void s(int b[], int n) {


while ( n > 0) {
for (int i=4; i > 0;i--) {
b[i] = b[i-1];
}
b[0] = n;
n--;
}
}
void p_a(int a[]) {
for (int i=0;i<5;i++) {
cout << a[i] << " ";
}
cout << endl;
}

main() {
int a[5] = { 9,8,7,6,5 };
p_a(a);
s(a,2);
p_a(a);
s(a,1);
p_a(a);
}

หน้า 11/12
ชื่อ-นามสกุล รหัสนักศึกษา Section

9 วิธีหนึ่งในการเก็บข้อมูลที่เป็นเลขจำานวนเต็มคือใช้ array 1 มิติเก็บตัวเลขแต่ละหลักโดยทุกหลักมีค่า 0 – 9 เช่น


จำานวน 123 จะเก็บใน array A ได้เป็น A[0] = 3 , A[1] = 2 และ A[2] = 1 เป็นต้น การเก็บเลขจำานวนเต็มด้วยวิธี
นี้สามารถเก็บเลขจำานวนเต็มที่มีขนาดใหญ่มากๆ (Big Integer) ได้ เช่นเลขขนาด 100 หลักเป็นต้น
จงเขียนฟังก์ชัน Add_BigInt เพื่อบวกเลข Big Integer หลักสองจำานวนเข้าด้วยกัน กำาหนดให้ฟังก์ชัน
Add_BigInt รับค่าและจำานวนหลักของเลข Big Integer สองจำานวน และคืนค่าเป็นคำาตอบและจำานวนหลักของ
คำาตอบ

void Input_BigInt(int [], int &);


void Add_BigInt(const int [], const int &,
const int [], const int &,
int [], int &);

main() {
int a[100], b[100], c[100];
int size_a, size_b, size_c;
Input_BigInt(a, size_a); // read 100-digit integer to A
Input_BigInt(b, size_b); // read 100-digit integer to B
Add_BigInt(a, size_a, b, size_b, c, size_c);
}

หมายเหตุ: สมมติให้ Input_BigInt อ่านค่ามาเก็บลงใน array a และ b ให้อัตโนมัติ ขนาดของ a และ b ไม่จำาเป็น
ต้องมีขนาดเท่ากัน และขนาดจะไม่เกิน 99 หลัก ตัวอย่างการบวกค่า 5 + 7 เท่ากับ 2 ทดไปหลักต่อไป 1
(10 คะแนน)

หน้า 12/12
ชื่อ-นามสกุล รหัสนักศึกษา Section

5 จงหาผลรันของโปรแกรมต่อไปนี้
5.1 (2 คะแนน)
#include <iostream>
using namespace std;
const int ASIZE = 8;
int main ()
{
int ar[ASIZE] = {0};
for (int i = 1; i < ASIZE; i = i + 2)
ar[i] = i * ASIZE;
for (int i = ASIZE - 1; i >= 0 ; --i)
cout << ar[i] << " " ;
cout << endl;
return 0;
}

5.2 (2 คะแนน)
#include <iostream>
using namespace std;
const int ASIZE = 4;
int main ()
{
int ar1[ASIZE] = {2, 3, 4, 5};
int ar2[ASIZE] = {4, 3, 2, 1};
int res = 0;
for (int i = 0; i < ASIZE; i++)
res += ar1[i] * ar2[ASIZE - i – 1];
cout << "Answer = " << res << endl ;
return 0;
}

หน้า 8/12
ชื่อ-นามสกุล รหัสนักศึกษา Section

5.3 (4 คะแนน)
#include <iostream>
using namespace std;
const int ASIZE = 4;
int main ()
{
int ar1[ASIZE] = {2, 3, 4};
int ar2[ASIZE] = { 2, -1, 0};
int ar3[ASIZE][ASIZE];
for (int i = 0; i < ASIZE; i++)
for (int j = 0; j < ASIZE; j++)
ar3[i][j] = ar1[i] * ar2[j];
for (int i = 0; i < ASIZE; i++)
{
for (int j = 0; j < ASIZE; j++)
cout << ar3[i][j] << '\t';
cout << endl;
}
return 0;
}

หน้า 9/12
ชื่อ-นามสกุล รหัสนักศึกษา Section

6 จงเขียนโปรแกรมเพื่อตรวจสอบว่าอะเรย์ของเลขจำานวนเต็มที่มีสมาชิก 13 ตัว ซึ่งรับจากแป้นพิมพ์ เป็นอะเรย์ที่สมมาตร


(symmetry) หรือไม่ ถ้าเป็นอะเรย์ที่สมมาตรก็ให้แสดงข้อความว่า "Symmetry" มิฉะนั้นก็ให้แสดงข้อความว่า
"Not symmetry"

อะเรย์ที่สมมาตร คือ อะเรย์ที่อ่านค่าสมาชิกจากตัวแรกไปตัวสุดท้ายจะได้ผลเหมือนการอ่านค่าสมาชิกจากตัวสุดท้าย


ย้อนกลับมาตัวแรก เช่น อะเรย์ที่มีสมาชิก 23, 33, 43, 33, 23 เป็นอะเรย์ที่สมมาตร ดังตัวอย่างการทำางานดังนี้

ตัวอย่างการทำางานเมื่อกรอก 1 2 3 4 5 6 7 8 9 0 1 2 3

Enter 13 integers: 1 2 3 4 5 6 7 8 9 0 1 2 3
Not symmetry.

ตัวอย่างการทำางานเมื่อกรอก 1 2 3 4 5 6 7 6 5 4 3 2 1
Enter 13 integers: 1 2 3 4 5 6 7 6 5 4 3 2 1
Symmetry.

(12 คะแนน)

หน้า 10/12
ชื่อ-นามสกุล รหัสนักศึกษา Section

7.2 (5 คะแนน)
#include <iostream>
using namespace std;
int main()
{
const int n=3;
int a[n][n], b[n] = {0}, c[n] = {0};
int i, j;

for (i=0; i<n; i++)


for(j=0; j<n; j++)
if (i<j) a[i][j] = j-i;
else if (i>j) a[i][j] = 2*(i-j);
else a[i][j] = 0;

for (i=0; i<n; i++)


for(j=0; j<n; j++)
{
b[i] += a[i][j];
c[j] += a[i][j];
}

cout << "array A: \n";


for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
cout << a[i][j] << ' ';
cout << endl;
}
cout << "array B: ";
for (i=0; i<n; i++) cout << b[i] << ' ';
cout << endl;

cout << "array C: ";


for (i=0; i<n; i++) cout << c[i] << ' ';
cout << endl;
return 0;
}

หน้า 10/11
ชื่อ-นามสกุล รหัสนักศึกษา Section

8 จงเขียนโปรแกรมภาษา C++ รับค่าจำานวนเต็ม n ตัวผ่านทางแป้นพิมพ์ โดยจัดเก็บไว้ในอาร์เรย์ a (สมมติว่า ผูใ้ ช้จะ


ป้อนค่าจำานวนเต็มโดยเรียงลำาดับจากน้อยไปหามากเสมอ) หลังจากนั้นให้โปรแกรมทำาการรับค่าจำานวนเต็ม x ผ่านทาง
แป้นพิมพ์ แล้วนำาค่าของ x ไปแทรกไว้ในอาร์เรย์ a โดยตำาแหน่งของ x ในอาร์เรย์ a จะต้องทำาให้อาร์เรย์ a ยังคงเรียง
ลำาดับจากน้อยไปหามาก แสดงผลลัพธ์ของอาร์เรย์ a ที่ได้ออกทางจอภาพตามตัวอย่างผลรันทีก่ ำาหนดให้
ตัวอย่างผลรัน
How many numbers in array A: 9
Enter 9 integers for array A: 1 2 3 4 5 7 8 9 10
Enter x: 6
The final array A: 1 2 3 4 5 6 7 8 9 10
(10 คะแนน)

หน้า 11/11
ชื่อ-นามสกุล รหัสนักศึกษา Section

3.2 (4 คะแนน)
#include <iostream.h>
void F1(float [], float&);

int main()
{
float a[] = {1.1, 2.0, 3.3, 4.4};
float b;

F1(a, b);
for (int i = 0; i < 4 ; i++)
cout << a[i] << '\t';
cout << '\n';
return 0;
}

void F1(float c[], float& d)


{
d = c[1];
for (int i = 0; i < 4 ; i++)
c[i] = d*c[i];
c[1] = d;
}

หน้า 5/11
ชื่อ-นามสกุล รหัสนักศึกษา Section

7 จงหาผลรันของโปรแกรมต่อไปนี้
7.1 (5 คะแนน)
#include <iostream>
using namespace std;
void swap(int& x, int& y)
{
int temp = x;
x = y;
y = temp;
}
int main()
{ const int n=3;
int a[n] = {2, 5, 6};
int b[n] = {1, 3, 4};
int i, j;

cout << "The beginning:\n";


cout << "array A: ";
for (i=0; i<n; i++) cout << a[i] << ' ';
cout << endl;
cout << "array B: ";
for (i=0; i<n; i++) cout << b[i] << ' ';
cout << endl;

while (b[0] < a[n-1])


{
swap(a[n-1], b[0]);
for (i = n-1; i > 0; i--)
if (a[i] < a[i-1]) swap(a[i], a[i-1]);
for (i = 0; i < n-1; i++)
if (b[i] > b[i+1]) swap(b[i], b[i+1]);
}

cout << "The results:\n";


cout << "array A: ";
for (i=0; i<n; i++) cout << a[i] << ' ';
cout << endl;
cout << "array B: ";
for (i=0; i<n; i++) cout << b[i] << ' ';
cout << endl;
return 0;
}

หน้า 9/11
ชื่อ-นามสกุล รหัสนักศึกษา Section

1. จงหาผลรันของโปรแกรมต่อไปนี้
1.1 (4 คะแนน)
#include <iostream.h>
#include <iomanip.h>
main() {
const int I = 2;
const int K = 3;
const int J = 2;
int A[I][K] = {{1, 2, 3},{1, 2, 3}};
int B[K][J] = {{1,2},{1,2},{1,2}};
int C[I][J];
for(int i=0; i<I; i++)
for(int j=0; j<J; j++) {
C[i][j] = 0;
for(int k=0; k<K; k++)
C[i][j] += A[i][k]*B[k][j];
}
cout << "[C] = " << endl;
for(int i=0; i < I; i++) {
for(int j=0; j<J; j++) {
cout << setw(4) << C[i][j] ;
}
cout << endl;
}
}

หน้า 2/14
ชื่อ-นามสกุล รหัสนักศึกษา Section

1.2 (4 คะแนน )
#include <iostream.h>
#include <iomanip.h>
const int NUM_STUDENTS = 3;
const int NUM_QUIZZES = 3;
typedef int Score[NUM_STUDENTS][NUM_QUIZZES];
void read(Score);
void printQuizAverages(Score);

int main() {
Score score = {{7, 8, 9}, {3, 4, 6}, {2}};
cout << "The quiz averages are:\n";
printQuizAverages(score);
return 0;
}

void read(Score score) {


for (int s = 0; s < NUM_STUDENTS; s++) {
cout << "Student " << s << ": ";
for (int q = 0; q < NUM_QUIZZES; q++)
cin >> score[s][q];
}
}

void printQuizAverages(Score score) {


for (int q = 0; q < NUM_QUIZZES; q++) {
float sum = 0.0;
for (int s = 0; s < NUM_STUDENTS; s++)
sum += score[s][q];
cout << "\tQuiz " << q+1 << ": "
<< sum/NUM_STUDENTS << endl;
}
}

หน้า 3/14
ชื่อ-นามสกุล รหัสนักศึกษา Section

2. จงเขียนโปรแกรมภาษา C++ รับข้อมูลนำ้าหนักของผู้ป่วยจำานวน 5 คนผ่านทางแป้นพิมพ์ ทำาการจัดเรียงข้อมูล


จากมากไปหาน้อย แล้วแสดงผลลัพธ์ที่ได้ออกทางจอภาพ (12 คะแนน)

ตัวอย่างผลรัน เมื่อกรอกข้อมูลเป็น 22.5 18.2 19.0 45.1 30.8 ตามลำาดับ


Please enter data for 5 people: 22.5 18.2 19.0 45.1 30.8
Data after sorting: 45.1 30.8 22.5 19 18.2

หน้า 4/14
ชื่อ สกุล รหัส Section

3. จงหำผลรันของโปรแกรมต่อไปนี้ (8 คะแนน)

#include <iostream>
using namespace std;
int main()
{
const int b_size = 15;
// array of non-zero positive integer
int a[] = { 2, 1, 2, 2, 7, 3, 5, 6, 7, 7, 8 };
int b[b_size] = {0};
int n = sizeof(a)/sizeof(int);
for (int i = 0; i < n ; i++)
for (int j = i+1; j < n; j++)
if ( a[j] == a[i] ) a[j] = -1;
for (int k = 0, i = 0; k < n; k++)
if (a[k] > 0) b[i++] = a[k];
for (int p = 0; p < n; p++)
cout << b[p] << " ";
cout << endl;
return 0;
}

4/10
ชื่อ สกุล รหัส Section

4. จงเขียนโปรแกรมเพื่อเปรียบเทียบสมำชิกของอะเรย์ของจำำนวนเต็ม a และ b ซึ่งเป็นอะเรย์ 2 มิติขนำด 2x3


จำำนวน 2 ชุด โดยอะเรย์ a มีคำ่ สมำชิกดังนี้

2 44 66
50 50 45

และอะเรย์ b มีค่ำสมำชิกดังนี้

33 44 55
50 50 50

กำำหนดให้เก็บผลลัพธ์กำรเปรียบเทียบอะเรย์ a และ b ลงในอะเรย์ c ทีม่ ีขนำดเท่ำกันกับอะเรย์ a และ b ดังนี้


• ถ้ำค่ำของสมำชิกในอะเรย์ a มีค่ำน้อยกว่ำค่ำของสมำชิกในอะเรย์ b ณ ตำำแหน่งเดียวกัน ให้กำำหนด
ค่ำ ของอะเรย์ c ณ ตำำแหน่งนัน้ เป็น -1
• ถ้ำค่ำของสมำชิกในอะเรย์ a มีค่ำเท่ำกับค่ำของสมำชิกในอะเรย์ b ณ ตำำแหน่งเดียวกัน ให้กำำหนดค่ำ
ของอะเรย์ c ณ ตำำแหน่งนั้นเป็น 0
• ถ้ำค่ำของสมำชิกในอะเรย์ a มีค่ำมำกกว่ำค่ำของสมำชิกในอะเรย์ b ณ ตำำแหน่งเดียวกัน ให้กำำหนด
ค่ำ ของอะเรย์ c ณ ตำำแหน่งนัน้ เป็น 1
แสดงผลลัพธ์ของอะเรย์ c ออกทำงจอภำพ (12 คะแนน)
ตัวอย่ำงผลรัน

-1 0 1
0 0 -1

5/10
ชื่อ สกุล รหัส Section

8. จงหำผลรันของโปรแกรมต่อไปนี้ (8 คะแนน)
#include <iostream>
using namespace std;
int index(int, int [], int, int);

int main( )
{
int a[] = {22,33,44,66,77,88,22,44,66};
cout << "index 1 = " << index(44,a,0,5) << endl;
cout << "index 2 = " << index(44,a,2,5) << endl;
cout << "index 3 = " << index(44,a,6,8) << endl;
cout << "index 4 = " << index(55,a,6,8) << endl;
return 0;
}

int index(int x, int a[], int lo, int hi)


{ int mid;
while (lo <= hi)
{ mid = (lo + hi)/2;
if (a[mid] == x) return mid;
if (a[mid] < x) lo = mid+1;
else hi = mid-1;
}
return 9;
}

9/10
ชื่อ สกุล รหัส Section

9. จงเขียนโปรแกรมภำษำ C++ รับค่ำสมำชิกของอำร์เรย์ a ขนำด 3 x 3 ผ่ำนทำงแป้นพิมพ์ แล้วทำำกำรสลับแถว


ข้อมูลของอำร์เรย์ a จำกแถวสุดท้ำยมำยังแถวแรก เก็บผลกำรสลับในอำร์เรย์ b แสดงผลลัพธ์ของอำร์เรย์ b ออก
ทำงจอภำพ เมื่อกำำหนดให้คำ่ สมำชิกในอำร์เรย์มีคำ่ เป็นจำำนวนเต็ม (12 คะแนน)

ตัวอย่ำงผลรัน เมื่อป้อนค่ำ (1,2,3), (4,5,6) และ (7,8,9) ให้กับอำร์เรย์ a ตำมลำำดับ


Input numbers for array a:
1 2 3
4 5 6
7 8 9
Result in array b:
7 8 9
4 5 6
1 2 3

10/10
ชื่อ สกุล รหัส Section

5. จงหำผลรันของโปรแกรมต่อไปนี้ (8 คะแนน)
#include <iostream>
using namespace std;
int main() {
int a[] = {24, 45, 93, 11, 87, 44, 22, 50, 76};
int size = sizeof(a) / sizeof(int);
for(int i = 0; i < size; i++)
cout << a[i] << " ";
cout << endl;
for(int i = 1; i < size; i++)
for(int j = 0; j < size - i; j++)
if (a[j] < a[j + 1]) {
int temp;
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
for(int i = 0; i < size; i++)
cout << a[i] << " ";
cout << endl;
cout << "Maximum = " << a[size - 1] << endl;
cout << "Median = " << a[size / 2] << endl;
cout << "Minimum = " << a[0] << endl;

return 0;
}

4/11
ชื่อ สกุล รหัส Section

6. จงเขียนโปรแกรมคำำนวณ B = A - AT กำำหนดให้ A และ B เป็นเมทริกซ์ (matrix) ของเลขจำำนวนเต็มขนำด 3x3


รับค่ำสมำชิกในเมทริกซ์ A ทั้งหมดจำกแป้นพิมพ์ คำำนวณและแสดงผลลัพธ์ในเมทริกซ์ B ออกทำงจอภำพ
Note: AT คือเมทริกซ์สลับเปลี่ยน (transpose) ของ A

[ ]
1 2 3
ตัวอย่ำงผลรัน เมื่อกรอกค่ำเมทริกซ์ A เป็น 4 5 6
7 8 9

Input values for the matrix A:


Row0: 1 2 3
Row1: 4 5 6
Row2: 7 8 9

Matrix B =
0 -2 -4
2 0 -2
4 2 0
(12 คะแนน)

5/11
ชื่อ สกุล รหัส Section

5.5 ฟังก์ชันต่อไปนีใ้ ช้ทำำงำนอะไร ? (1 คะแนน)


int func5(int x, int a[], int n) {
int lo = 0, hi = n - 1, i;
while (lo <= hi) {
i = (lo + hi)/2;
if (a[i] == x) return i;
if (a[i] < x)
lo = i + 1;
else
hi = i – 1;
}
return n;
}
ก. กำรสืบค้นข้อมูลแบบ Linear Search ข. กำรสืบค้นข้อมูลแบบ Binary Search
ค. กำรสลับค่ำ (Swap) ง. กำรจัดเรียงข้อมูลแบบ Bubble Sort
จ. กำรทำำ Transpose

6. จงหำผลรันของโปรแกรมต่อไปนี้
#include <iostream>
using namespace std;
int main() {
int A[][4] = {{3, 3, 5, 7}, {1, 2, 3, 4}, {5, 4, 3, 2}};
for(int i = 0; i < 3; i++) {
int bb = 0;
for(int j = 0; j < 4; j++)
bb += A[i][j];
cout << bb << endl;
}
for(int i = 0; i < 4; i++) {
int cc = 0;
for(int j = 0; j < 3; j++)
cc += A[j][i];
cout << cc << endl;
}
return 0;
}
(3 คะแนน)

8/11
ชื่อ สกุล รหัส Section

7. จงเขียนโปรแกรมภำษำ C++ คำำนวณและแสดงค่ำเฉลี่ย (Mean) และค่ำเบี่ยงเบนมำตรฐำน (Standard


Deviation) ของคะแนนสอบในห้องที่มีนักเรียนจำำนวน 15 คน โดยมีข้อกำำหนดดังต่อไปนี้
• รับค่ำคะแนนสอบ (เต็ม 10 คะแนน) ของนักเรียนแต่ละคนจำกแป้นพิมพ์เข้ำมำเก็บไว้ในอำร์เรย์ A
• หำค่ำเฉลี่ยจำกสูตร
N −1

∑ ai
μ= i=0
N
• หำค่ำเบี่ยงเบนมำตรฐำนจำกสูตร


N −1

∑ ( a i−μ)
i=0
σ=
N
ตัวอย่ำงผลรัน
Please enter scores for 15 students:
3 10 4 2 3 6 9 3 10 10 3 7 0 6 1
Mean = 5.13333
SD = 3.30387
(12 คะแนน)

9/11
ชื่อ สกุล รหัส Section

6. จงเขียนโปรแกรมภำษำ C++ จงหำผลรันของโปรแกรมต่อไปนี้ (8 คะแนน)


#include <iostream>
#include <cmath>
const int m=2;
const int n=3;
using namespace std;
int main()
{
int i, j;
int x[m][n]={{4,5,6},
{7,8,6}};
float sum2, result;
for(i = 0; i < m; i++) {
for(j = 0; j < n; j++) {
if(x[i][j] > 0)
sum2 = sum2 + x[i][j];
}
result = sqrt(sum2);
}
cout << "\nFirst, summing up all the arrays' element";
cout << "\nThe given array has 2 x 3 in size,\n";
cout << "\nThe sum is = " << sum2;
cout << "\nNext, square root the sum\n";
cout << "\nThe answer is = " << result << "\n";
return 0;
}

7/11
ชื่อ สกุล รหัส Section

7. จงเขียนโปรแกรมภำษำ C++ รับค่ำสมำชิกของอำร์เรย์ a ขนำด 3 x 3 ผ่ำนทำงแป้นพิมพ์ แล้วทำำกำรสลับคอลัมน์ของ


อำร์เรย์ a จำกคอลัมน์สดุ ท้ำยมำเป็นคอลัมน์แรก เก็บผลกำรสลับในอำร์เรย์ b แล้วแสดงผลลัพธ์ของอำร์เรย์ b ออก
ทำงจอภำพ เมื่อกำำหนดให้ค่ำสมำชิกในอำร์เรย์มีค่ำเป็นจำำนวนเต็ม (12 คะแนน)

ตัวอย่ำงผลรัน เมื่อป้อนค่ำ (1,2,3) (4,5,6) (7,8,9) ให้กับอำร์เรย์ a ตำมลำำดับ


Input numbers for array a:
1 2 3
4 5 6
7 8 9
Result in array b:
3 2 1
6 5 4
9 8 7

8/11
ชื่อ สกุล______________________________________ รหัส____________________ Section______ เลขที่นั่งสอบ______
 
3. จงเขียนโปรแกรมรับคาขอมูลเมทริกซจํานวนเต็มสองเมทริกซ ขนาด 3x3 และ 3x3 คํานวณหาผลคูณ แลวแสดงคาทีค่ ํานวณได
ทางจอภาพ โดยใช for loop ใหแสดงผลเหมือนกับตัวอยางผลการทํางาน (12 คะแนน)
2
โดยที่สมาชิกแตละตัวของเมทริกซผลคูณคือ ci, j = ∑ ai,k ⋅ bk, j
k=0

ตัวอยางผลรัน (ตัวหนาคือขอมูลที่ปอน)
Input matrix A:

Row 0: 1 2 3

Row 1: 4 5 6

Row 2: 7 8 9

Input matrix B:

Row 0: 1 0 2

Row 1: 0 1 2

Row 2: 3 2 1
 
1 2 3 1 0 2 10 8 9

4 5 6 x 0 1 2 = 22 17 24

7 8 9 3 2 1 34 26 39

   

Page  5  of  12  


 
ชื่อ สกุล______________________________________ รหัส____________________ Section______ เลขที่นั่งสอบ______
 
4. จงหาผลการทํางานของโปรแกรม ตอไปนี้ (8 ตะแนน)

#include <iostream>
using namespace std;

void printA(int []);

main() {
int a[5] = {1,2,3,4,5};
int b[5];

printA(a);
for(int i=0;i<4;i++) {
a[i] = a[i+1];
}

printA(a);

a[0]=1; a[1]=2;a[2]=0;a[3]=0;a[4]=0;
printA(a);

for(int i=0;i<5;i++) {
b[i] = a[4-i];
}

printA(b);

int c[2][5] ={ {1,2,3,4,5},{5,4,3,2,1} };


int d[5] = {0};
int i = 1;
d[0] = c[1][2] + c[2][3];
d[i] = c[i][i];
d[i+1] = c[i][i+1];
printA(d);

void printA(int x[]) {


for (int i=0;i<5;i++) {
cout << x[i] << " ";
}
cout << endl;
}

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

_____________________________________________________________________________________

Page  7  of  12  


 
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

6. จงเขียนโปรแกรมสาหรับสร้างเมทริกซ์ (matrix) สมมาตรจากสมการ B = A + AT กาหนดให้ A และ B เป็นเมทริกซ์ของเลข


จานวนเต็มขนาด 4x4 กาหนดให้รบั ค่าสมาชิกในเมทริกซ์ A ทั้งหมดจากแป้นพิมพ์เก็บไว้ในอาเรย์ 2 มิติ คานวณและเก็บผลลัพธ์ใน
เมทริกซ์ B แล้วแสดงผลออกทางจอภาพ (12 คะแนน)

Note: AT คือเมทริกซ์สลับเปลีย่ น (transpose) ของ A

ตัวอย่างผลรัน

0 1 2 3 0 0 0 0
0 0 1 2 1 0 0 0
เมื่อกรอกค่าเมทริกซ์ A เป็น  จะได้ AT มีค่าเป็น 
0 0 0 1 2 1 0 0
   
0 0 0 0 3 2 1 0

Input values for the matrix A:


Row0: 0 1 2 3
Row1: 0 0 1 2
Row2: 0 0 0 1
Row3: 0 0 0 0

Matrix B =
0 1 2 3
1 0 1 2
2 1 0 1
3 2 1 0

หน้าที่ 11/14
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

7. จงหาผลการทางานของโปรแกรมต่อไปนี้
#include <iostream>
using namespace std;

int main()
{
int myArray[4][4], index1, index2;

for(index1 = 0; index1 < 4; index1++)


for(index2 = 0; index2 < 4; index2++)
myArray[index1][index2] = index2;

for(index1 = 0; index1 < 4; index1++){


for(index2 = 0; index2 < 4-index1; index2++)
cout<<myArray[index1][index2]<<" ";
cout<<endl;
}
return 0;
}
(3 คะแนน)

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

#include <iostream>
using namespace std;

int A(int arr[][5], int r, int c) {


int m = arr[0][0];
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
if (arr[i][j] < m) m = arr[i][j];
return m;
}

float B(int arr[][5], int r, int c) {


float temp=0;
for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
temp+=arr[i][j];
return temp/(r*c);
}

int C(int arr[][5], int x, int r, int c) {


for (int i = 0; i < r; i++)
for (int j = 0; j < c; j++)
if(x==arr[i][j])
return i+j;
return -1;
}

หน้าที่ 13/14
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

int main() {
int x[3][5] = { {13,4,35,22,3},
{30,3,7,9,2},
{3,4,4,9,2}};
cout << A(x, 3, 5) << endl;
cout << B(x, 3, 5) << endl;
cout << C(x,9,3,5) << endl;
cout << C(x,12,3,5) << endl;
return 0;
}

(5 คะแนน)

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

______________________________________________________________________________________________

หน้าที่ 14/14
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

5. จงเขียนโปรแกรมเพื่อคํานวณค่า Pascal’s Triangle ในรูปแบบของ Array 2 มิติขนาด 4x4 ตามตัวอย่างดังนี้


( 12 คะแนน)

ค่าใน Array ตัวอย่างผลการทํางาน


1 1 1 1
1 1 1 1
1 2 3 4 1 2 3 4
1 3 6 10 1 3 6 10
1 4 10 20 1 4 10 20
โดยโปรแกรมจะต้องใช้ for loop คํานวณค่าและเก็บค่าที่คํานวณได้ใน array แล้วทําการแสดงผลทางจอภาพ โดยค่าที่
อยู่ใน array จะต้องทําการคํานวณจากวิธีดังต่อไปนี้
a) ให้ใส่ค่าใน array แถวแรกดัวย 1 และคอลัมน์แรกด้วย 1
b) ค่าในแต่ละช่องหลังจากนั้นจะเท่ากับค่าในช่องก่อนหน้าในแถวเดียวกันบวกด้วยค่าในช่องข้างบนที่
คอลัมน์ตรงกัน
c) การคํานวณจะต้องทําจากซ้ายไปขวาและจากบนลงล่าง โดยเริ่มจากตัวถัดจากตัวแรกและแถวถัดจาก
แถวแรก
d) พิมพ์ผลลัพธ์ตามตัวอย่าง คือตั้งความกว้าง 4 ตัวอักษร

หน้าที่ 6 / 10
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

6. จงหาผลการทํางานของโปรแกรม (8 คะแนน)
#include <iostream>
using namespace std;

main() {
int a[2][5] = {{1,2,3,4,5}, {0,0,0,0,0}};

for (int i=0; i<5; i++)


cout << a[0][i] << “ “;
cout << endl;

for (int i=1;i<4;i++)


a[1][i] = a[0][i-1];

for(int i=0; i<5; i++)


cout << a[1][i] << “ “;
cout << endl;

int b[5];

b[0] = 1;
b[1] = b[0] + 1;
b[2] = a[0][3];
b[3] = b[0] + b[1];
b[4] = b[b[0] + 1];

for(int i=0;i<5;i++)
cout << b[i] << “ “;
cout << endl;

int c[2][2][2] = {{{1,2},{3,4}},{{5,6},{7,8}}};


cout << c[0][1][0] << endl;

______________________________________________________________________________________________________

______________________________________________________________________________________________________

______________________________________________________________________________________________________

______________________________________________________________________________________________________

______________________________________________________________________________________________________

______________________________________________________________________________________________________

______________________________________________________________________________________________________

______________________________________________________________________________________________________

หน้าที่ 7 / 10
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

10. [10 คะแนน] รูปภาพสามารถแทนดวย array 2 มิติ โดยมีขอมูลใน array เปนจํานวนเต็ม ในการกลับรูปภาพ (flip)
สามารถทําไดโดยการกลับขอมูลใน array โดยปกติการกลับรูปสามารถทําได 2 แนว คือ แนวตั้ง (horizontal) หรือ
แนวนอน (vertical)
จงเขียนฟงกชัน flip ที่ไมสงขอมูลกลับ (void function) โดยรับสงคา array 2 มิติ ขนาด 100 x 100
และวิธีการกลับเปนคาจํานวนเต็ม โดย 0 เปนการกลับรูปแนวตั้งและ 1 เปนการกลับรูป แนวนอน โดยฟงกชัน ทําการ
flip คาใน array ตามวิธีการกลับภาพและ
จงเขียนโปรแกรม main ที่เรียกใชฟงกชันดังกลาว
การกลับรูปแนวตั้งทําไดโดยสลับที่ขอมูลคอลัมนแรกกับขอมูลคอลัมนสุดทาย ขอมูลคอลัมนตัวถัดมากับขอมูล
คอลัมนรองสุดทาย ทําจนกระทั่งถึงขอมูลตัวตรงกลางการกลับรูปแนวนอนทําไดโดยสลับที่ขอมูลแถวแรก
กับขอมูลแถวสุดทาย ขอมูลแถวตัวถัดมากับขอมูลแถว รองสุดทาย ทําจนกระทั่งถึงขอมูล ตัวตรงกลาง
ตัวอยางการ flip สําหรับ array 4x4
กอน หลัง horizontal flip กอน หลัง vertical flip
1 2 3 4 4 3 2 1 1 2 3 4 13 14 15 16
5 6 7 8 8 7 6 5 5 6 7 8 9 10 11 12
9 10 11 12 12 11 10 9 9 10 11 12 5 6 7 8
13 14 15 16 16 15 14 13 13 14 15 16 1 2 3 4

หนาที่ 12 / 13
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

3. [5 คะแนน] หาผลรันของโปรแกรมตอไปนี้
#include <iostream>
using namespace std;

void printArray(int [],int );

const int N=5;

int main(){
int sizea,sizeb;
int a[N] = {1};
int b[] = {5,4,3};
sizea = sizeof(a)/sizeof(int);
sizeb = sizeof(b)/sizeof(int);
cout<<"a[] = ";
printArray(a,sizea);
cout<<"b[] = ";
printArray(b,sizeb);

int i,n=1;
printArray(a,n);
i=n++;
a[i]=2;
printArray(a,n);

for(int idx=0; idx<3; idx++){


i=n++;
a[i]=b[idx];
if (a[i-1]<a[i]) swap(a[i],a[i-1]);
}
printArray(a,n);
return 0;
}

void printArray(int a[],int n){


for(int i=0; i<n; i++) cout<<a[i]<<" ";
cout<<endl;
}

(หมายเหตุ ___ หมายถึงการแสดงผลรัน 1 อักขระ)

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

หนาที่ 5 / 13
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

4. [3 คะแนน] หาผลรันของโปรแกรมตอไปนี้
#include <iostream>
using namespace std;

int main()
{
int A[3][3] = {{1,2,3}, {1,2,3}, {1,1,1}};
int rowA[3] = {0};
int colA[3] = {0,0,0};

int allA = 0;
for(int i=0; i<3; i++)
{
for(int j=0; j<3; j++)
{
if(A[i][j]==1) rowA[i]++;
colA[j]+=A[i][j];
allA+=A[i][j];
}
}

cout<<"allA = "<<allA<<endl;

cout<<"rowA =";
for(int i=0; i<3; i++) cout<<"\t"<<rowA[i]<<endl;

cout<<"colA = ";
for(int i=0; i<3; i++) cout<<colA[i]<<" ";
return 0;
}

(หมายเหตุ ___ หมายถึงการแสดงผลรัน 1 อักขระ)

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

หนาที่ 6 / 13
ชื่อ สกุล________________________________________ รหัส_________________ Section_______ เลขที่นั่งสอบ_______

5. Tony Stark ตองการจะทําลายหุน Iron Man ทั้งหมดใหเร็วที่สุดเพื่อจบความวุนวายทั้งมวล แตเขาก็ตองการเก็บหุน


ตัวลาสุดไวหนึ่งตัวเผื่อกรณีฉุกเฉิน Tony จึงสั่งให JARVIS ทําลายหุนที่เหลือทิ้งซะ อยางไรก็ตาม JARVIS โดนไวรัสบุก
เพราะ Pepper แอบไปโหลดเกมจากอินเตอรเน็ตอยางผิดลิขสิทธิ์มาเลนกับ JARVIS ทําให JARVIS ไมสามารถ
ทํางานไดตามปกติ คุณในฐานะเลขาของ Pepper จึงตองลงมือเขียนโปรแกรมใหมอยางรวดเร็วโดยใชรายละเอียด
และขั้นตอนตอไปนี้

  [2 คะแนน]
• เขียนรับจํานวนหุน iron man มาจากผูใช
• สราง array ขึ้นมาเพื่อเก็บรหัสประจําตัวของหุน

  [3 คะแนน]
• รับรหัสประจําตัวของหุนซึ่งเปนเลขจํานวนเต็มบวกเขามาใสใน array ตามลําดับการใสจากผูใช
• แสดงรหัสของหุนทั้งหมดใน array

  [6 คะแนน]
• ทําการเปลี่ยนรหัสของหุนใน array เปนคา -1 ทั้งหมด เพื่อเปนการทําลายหุน
• ยกเวนใหเก็บหุนตัวลาสุดไวซึ่งคือหุนตัวที่มีรหัสสูงที่สุด โดยไมตองเปลี่ยนคาเปน -1 ใหเก็บคาเดิมไว

[1 คะแนน]
• แสดงรหัสของหุนทั้งหมดใน array หลังจากการแกแลว

ตัวอยางผลรัน โดยตัวหนาคือ input ที่รับเขามา


Enter iron man count: 5
Enter 5 iron man IDs: 34 56 900 76 39
Current iron mans: 34 56 900 76 39
Max ID = 900
Current iron mans: -1 -1 900 -1 -1

ตัวอยางผลรัน โดยตัวหนาคือ input ที่รับเขามา


Enter iron man count: 7
Enter 5 iron man IDs: 11 45 9 23 108 113 51
Current iron mans: 11 45 9 23 108 113 51
Max ID = 113
Current iron mans: -1 -1 -1 -1 -1 113 -1

หนาที่ 7 / 13
ชื่อ-สกุล ___________________________________ รหัสนักศึกษา __________________ section ______ เลขที่นั่งสอบ _______

5. (5 คะแนน) จงหาผลรันของโปรแกรมต่อไปนี้
5.1
int main()
{
const int SIZE = 10;
int a[SIZE] = {2, 4, 6, 8, 10};
for(int i = 0; i < SIZE; i += 2){
cout << a[i] << ' ';
}
return 0;
}

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

5.2
int main()
{
char cm[3][3] = { 'a', 'n', 't',
'b', 'a', 't',
'c', 'a', 't'};
for(int i=0; i<3; i++){
for(int j=0; j<3; j++)
cout << cm[j][i] << ' ';
cout << endl;
}
return 0;
}

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___

หน้าที่ 7 / 16
ชื่อ-สกุล ___________________________________ รหัสนักศึกษา __________________ section ______ เลขที่นั่งสอบ _______

6. (10 คะแนน) การแก้ระบบสมการเส้นตรงที่มีสมการตั้งแต่ 1 สมการขึ้นไป ทาได้โดยแทนระบบสมการให้อยู่ในรูป


เมทริกซ์ (เรียกกันว่า เมทริกซ์แต่งเติม) แล้วใช้กระบวนการที่เรียกว่า การดาเนินการตามแถวขั้นมูลฐาน ในการหา
คาตอบ การดาเนินการตามแถวขั้นมูลฐาน ประกอบไปด้วย 3 การดาเนินการ คือ
1) การคูณแถวใดแถวหนึ่งด้วยเลขจานวนจริง
2) การสลับแถวสองแถว
3) การเอาแถวใดแถวหนึ่งคูณกับจานวนจริงแล้วบวกกับอีกแถว

จงเขียนโปรแกรมภาษา C++ เพื่อรับค่าเมทริกซ์ขนาด 3x3 แล้ววนรับคาสั่งของผู้ใช้ ดังนี้


 เมื่อผู้ใช้ป้อนคาสั่งเป็น 1 ให้รับตัวเลขแถว และเลขจานวนจริงแล้วทาการคูณแถวนั้นด้วยเลขจานวนจริง
 เมื่อผู้ใช้ป้อนคาสั่งเป็น 2 ให้รับเลขแถวสองแถว แล้วทาการสลับแถว
 เมื่อผู้ใช้ป้อนคาสั่งเป็น 3 ให้รับเลขแถวสองแถว (rowA และ rowB) และเลขจานวนจริง (x) แล้วแทนที่แถว
แรกที่ป้อนด้วยแถวแรก บวกด้วยแถวที่สองคูณด้วยจานวนจริง นั่นคือ rowA = rowA + x*rowB
 เมื่อผู้ใช้ป้อนคาสั่งเป็น 0 ให้ออกจากโปรแกรม
 เมื่อผู้ใช้ป้อนค่าอื่นๆ ไม่ต้องดาเนินการใดๆกับเมทริกซ์

แสดงผลที่ได้ดังตัวอย่างต่อไปนี้ โดยตัวหนาคือค่าที่ผู้ใช้ป้อนเข้าไป
Enter your matrix: 1 2 3 4 5 6 7 8 9
Enter your command: 1
Enter row number: 1
Enter constant: 2
Output:
2 4 6
4 5 6
7 8 9
Enter your command: 2
Enter two rows number to swap: 2 3
Output:
2 4 6
7 8 9
4 5 6
Enter your command: 3
Enter 1st row, 2nd row and constant: 3 1 -2
Output:
2 4 6
7 8 9
0 -3 -6
Enter your command: 9
Output:
2 4 6
7 8 9
0 -3 -6
Enter your command: 0

หน้าที่ 8 / 16
ชื่อ-สกุล ___________________________________ รหัสนักศึกษา __________________ section ______ เลขทีน่ ั่งสอบ _______

5. (12 คะแนน) จงเขียนโปรแกรมภาษา C++ เพื่อรับค่าข้อมูลเมทริกซ์จานวนเต็มขนาด 4x4 ตามตัวอย่างผลการทางาน


ด้านล่าง จากนั้นให้รับค่าจานวนเต็ม x ที่ต้องการค้นหาในเมทริกซ์ ทาการค้นหา แล้วแสดงตาแหน่งที่คน้ หาเจอเป็น
ตาแหน่งแรกออกทางจอภาพ โดยให้ทาการค้นหาจากซ้ายไปขวาและบนลงล่าง ถ้าไม่เจอจานวนเต็ม x ในเมทริกซ์ให้
แสดงข้อความออกทางจอภาพว่า “Not Found!”

ตัวอย่างผลรันที่ 1 เมื่อผู้ใช้ป้อนค่า 1 2 3 4 4 5 6 5 7 8 9 1 4 5 6 0 และ 6 ตามลาดับผ่านทางแป้นพิมพ์ (ตัวหนา


คือค่าที่ผู้ใช้ป้อนผ่านทางแป้นพิมพ์)
Input matrix A:

Row 0: 1 2 3
4
Row 1: 4 5 6
5
Row 2: 7 8 9
1
Row 3: 4 5 6
0
Enter search value: 6
Found 6 at A[1][2]

ตัวอย่างผลรันที่ 2 เมื่อผู้ใช้ป้อนค่า 1 2 3 4 4 5 6 5 7 8 9 1 4 5 6 0 และ 77 ตามลาดับผ่านทางแป้นพิมพ์


(ตัวหนาคือค่าที่ผู้ใช้ป้อนผ่านทางแป้นพิมพ์)
Input matrix A:

Row 0: 1 2 3 4
Row 1: 4 5 6 5
Row 2: 7 8 9 1
Row 3: 4 5 6 0
Enter search value: 77
Not Found!

หน้าที่ 7 / 13
ชื่อ-สกุล ___________________________________ รหัสนักศึกษา __________________ section ______ เลขทีน่ ั่งสอบ _______

6. (8 คะแนน) จงหาผลการทางานของโปรแกรม ตอไปนี้

#include <iostream>
using namespace std;

int main()
{
const int n =5;
int a[][] = {{1,2,3},{2,3,4},{3,4,5}};
int b[n][n] = {0};
for(int i=1; i<n-1; i++){
for(int j=1; j<n-1; j++){
if (j!=i)
b[i][j] = a[i-1][j-1] + a[j-1][i-1];
}
}
for(int x=0; x<n; x++){
for(int y=0; y<n; y++){
cout << b[x][y] << ' ';
}
cout << endl;
}
return 0;
}

ให้กรอกผลการทางานในช่องที่กาหนดให้ด้านล่าง
โดยกาหนดให้ 1 ช่อง คือ อักขระ 1 ตัว ที่จะแสดงผลออกทางจอภาพ
———————————————————————————————————

———————————————————————————————————

———————————————————————————————————

———————————————————————————————————

———————————————————————————————————

———————————————————————————————————

———————————————————————————————————

———————————————————————————————————

หน้าที่ 9 / 13
ชื่อ-สกุล __________________________________ รหัสนักศึกษา __________________ section ______ เลขที่นั่งสอบ _______

2 จงตอบคําถาม ต่อไปนี้
2.1 (5 คะแนน) จงหาผลรันของโปรแกรมต่อไปนี้
#include <iostream>
using namespace std;

int main()
{
int a[4][4] = {{5, 1, 8, 6}, {2, 3, 6, 3}, {4, 6, 4, 7},
{8, 1, 3, 3}};
int row[4] = {0};
int column[4] = {0};

for(int i=0; i<4; i++){


for(int j=0; j<4; j++){
row[i] += a[i][j];
column[j] += a[i][j];
}
}

for(int i=0; i<4; i++){


cout << row[i] << endl;
}

for(int i=0; i<4; i++){


cout << column[i] << " ";
}

return 0;
}

ให้กรอกผลการทํางานในช่องที่กําหนดให้ด้านล่าง ให้ 1 ช่อง คือ 1 อักขระ ที่จะแสดงผลออกทางจอภาพ

——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————

หน้าที่ 4 / 14
ชื่อ-สกุล __________________________________ รหัสนักศึกษา __________________ section ______ เลขที่นั่งสอบ _______

2.2 (5 คะแนน) จงหาผลรันของโปรแกรมต่อไปนี้


#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int N = 5;
int arrayA[N][N] = {0};

for(int i=0; i<N; i++){


for(int j=0; j<=i; j++){
if(i==0||i==1)
arrayA[i][j] = 1;
else
arrayA[i][j]=arrayA[i-1][j-1]+arrayA[i-1][j];
}
}

for(int i=0; i<N; i++){


for(int j=0; j<=i; j++)
cout << setw(4) << arrayA[i][j];
cout << endl;
}

return 0;
}

ให้กรอกผลการทํางานในช่องที่กําหนดให้ด้านล่าง ให้ 1 ช่อง คือ 1 อักขระ ที่จะแสดงผลออกทางจอภาพ

——————————————————————————————

——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————
——————————————————————————————

หน้าที่ 5 / 14
ชื่อ-สกุล __________________________________ รหัสนักศึกษา __________________ section ______ เลขที่นั่งสอบ _______

3 (10 คะแนน) จงเขียนโปรแกรมภาษา C++ เพื่อทําการอ่านอาเรย์ของเลขจํานวนเต็ม 5 จํานวนสองอาเรย์ แล้ว


ทําการรวมอาเรย์ทั้งสองเพื่อสร้างอาเรย์ใหม่ หลังจากนั้นทําการจัดเรียงข้อมูลจากน้อยไปมากแล้วแสดงผล

ตัวอย่างผลรัน เมื่อผู้ใช้ป้อนค่าอาเรย์ A เป็น 4 1 3 5 2 และ ป้อนค่าอาเรย์ B เป็น 10 6 9 8 7


Enter array A: 4 1 3 5 2
Enter array B: 10 6 9 8 7
Result : 1 2 3 4 5 6 7 8 9 10

หน้าที่ 6 / 14
ชื#อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที#นงั# สอบ ______

5. จงหาผลรันของโปรแกรมต่อไปนี=
5.1 (4 คะแนน)
#include <iostream>
using namespace std;
void print(int a[], int n)
{
for(int i=0; i<n; i++)
cout << a[i] << ' ';
cout << endl;
}
int main(){
int a[5] = {1,2,3,4,5};
int b[5] = {1};
int c[5] = {5,4,3,2,1};
for(int i=0; i<5; i++)
c[i] += a[i];
int d[] = {3,3,3};
cout<<"a = ";
print(a,5);
cout<<"b = ";
print(b,5);
cout<<"c = ";
print(c,5);
int size = sizeof(d)/sizeof(int);
cout<<"D = ";
print(d,size);
return 0;
}

( __ หมายถึง หนึ#งตัวอักขระ)

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

หน้าที# 8 / 18

ชื#อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที#นงั# สอบ ______

6. (12 คะแนน) โรงงานแห่ งหนึ# งมี การเก็บ สถิ ติป ระสิ ท ธิ ภาพเครื# องมื อจากการปรั บ ค่าควบคุ มเครื# องมื อในแต่ละวัน
เป็ นจํานวนทั=ง สิ= น 10 วัน โดยค่ าควบคุ ม ที# เก็ บ ได้แ ก่ อุ ณ หภู มิ ความเร็ ว รอบ และ อัต ราการฉี ด พ่ น นอกจากนี=
โรงงานยังได้ทาํ การบันทึกค่าประเมินคุณภาพชิ=นงาน (ในหน่วยคะแนนเต็ม 1) ที#เป็ นผลจากค่าควบคุมที#กาํ หนด
ให้ เ ขี ย นโปรแกรมภาษา C++ ทํ า การรั บ ค่ า ต่ า ง ๆ เก็ บ ไว้ใ นอาเรย์ แล้ ว แสดงผลข้ อ มู ล ในแต่ ล ะวัน
รวม ทั= งค่ าป ระเมิ น คุ ณ ภ าพ ชิ= น งาน สู งสุ ด ที# เค ยได้ รั บ ตั= งแ ต่ วั น แ รก จน ถึ งวั น ดั ง ก ล่ าว ห ลั ง จาก นั= น
จึ ง แ ส ด ง ผ ล ข อ ง ค่ า ค ว บ คุ ม ใ น วั น ที# มี ค่ า ป ร ะ เมิ น คุ ณ ภ า พ ชิ= น ง า น สู ง สุ ด เป็ น ค รั= ง แ ร ก แ ล ะ
แสดงค่าคุณภาพชิ=นงานในหน่วยร้อยละ
ตัวอย่างผลรัน
Enter data for 10 days (TEMP RPM SPR Score):
25 12 10 0.5
26 12 10 0.55
26 11 10 0.45
26 11 11 0.475
27 11 10 0.6
30 12 15 0.8
32 12 13 0.7
32 13 14 0.8
31 14 15 0.75
31 15 15 0.76

Day TEMP RPM SPR Score BestScore


1 25 12 10 0.5 0.5
2 26 12 10 0.55 0.55
3 26 11 10 0.45 0.55
4 26 11 11 0.475 0.55
5 27 11 10 0.6 0.6
6 30 12 15 0.8 0.8
7 32 12 13 0.7 0.8
8 32 13 14 0.8 0.8
9 31 14 15 0.75 0.8
10 31 15 15 0.76 0.8

Best known setting:


TEMP = 30 degree Celsius
RPM = 12 rpm.
SPR = 15 ml/sec.
Highest score is 80%

หน้าที# 10 / 18

ชื#อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที#นงั# สอบ ______

5.2 (4 คะแนน)
#include <iostream>
using namespace std;
int main()
{
int a[2][3] = {{1,2,3}, {4,5,6}};
for(int i=0; i<2; i++){
for(int j=0; j<3; j++)
cout << a[i][j] << ' ';
cout << endl;
}
cout << endl;
for(int i=0; i<3; i++){
for(int j=0; j<2; j++)
cout << a[j][i] << ' ';
cout << endl;
}
return 0;
}

( __ หมายถึง หนึ#งตัวอักขระ)

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

หน้าที# 9 / 18

ชื่อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที่นงั่ สอบ ______

6. (8 คะแนน) จงหำผลรันของโปรแกรมต่อไปนี้
#include <iostream>
using namespace std; typedef float TABLE[2][3];
main() {
int A[5] = {1, 2, 3, 4, 5}; int B[50] = {0}; TABLE C = {{5.5, 6.1, 8.9}, {9.7, 10.0, 8.7}};
int size1 = sizeof(A)/sizeof(int); int size2 = sizeof(B)/sizeof(int);
for (int i = 0; i < size1; i++)
B[i*2] = A[i];
for (int i = 1; i < size1; i++)
A[i] += A[i-1];
for (int i = 0; i < size1; i++)
cout << A[i] << " ";
cout << endl;
for (int i = 0; i < size2-40; i++)
cout << B[i] << " ";
cout << endl;
for (int i = 0; i < 2; i++) {
float sum = 0;
for (int j = 0; j < 3; j++)
sum += C[i][j];
cout << sum << endl;
}
for (int i = 0; i < 3; i++) {
float sum = 0;
for (int j = 0; j < 2; j++)
sum += C[j][i];
cout << sum << endl;
}
}
( __ หมำยถึง หนึ่งตัวอักขระ)
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

หน้ าที่ 8 / 16
ชื่อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที่นงั่ สอบ ______

7. (12 คะแนน) กำหนดให้เมตริกซ์ A และเมตริกซ์ B มีขนำด 3X3 เท่ำกัน ส่วนเมตริกซ์ C มีขนำด 3X6 สมำชิกของเมตริกซ์
C ได้มำจำกสมำชิกของเมตริกซ์ A และเมตริกซ์ B โดยที่สมำชิกที่มีหลัก (column index) เป็นเลขคู่ของเมตริกซ์ C ได้มำ
จำกสมำชิกของเมตริกซ์ A และสมำชิกที่มีหลัก (column index) เป็นเลขคี่ของเมตริกซ์ C ได้มำจำกสมำชิกของเมตริกซ์ B
จงเขียนโปรแกรมภำษำ C++ รับข้อมูลค่ำสมำชิกของเมตริกซ์ A และเมตริกซ์ B จำกแป้นพิมพ์ แล้วทำกำรหำเมตริกซ์ C
จำกนั้นแสดงผลเมตริกซ์ C ออกทำงจอภำพ
ตัวอย่ำงผลรันโปรแกรม (ตัวอักษรหนาหมำยถึงค่ำที่ผู้ใช้ป้อน)
Enter 3x3 values for [A]:
123
123
123
Enter 3x3 values for [B]:
456
456
456
[C] =
1 4 2 5 3 6
1 4 2 5 3 6
1 4 2 5 3 6

หน้ าที่ 9 / 16
ชื่อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที่นงั่ สอบ ______

5. (4 คะแนน) จงหำผลรันของโปรแกรมต่อไปนี้ เมื่อป้อนข้อมูลตำมนี้ (ตัวอักษรเข้ม คือ ค่ำที่รับผ่ำนทำงแป้นพิมพ์)


enter the array
1 12 2 25 3 35 4 48 5 55
#include <iostream>
using namespace std;
int main()
{
int a[10],i,b=0,N=10;
cout<<"enter the array\n";
for(int i=0;i<N;i++)
{
cin>>a[i];
if (a[i]>=10)
b++;
}
cout<<"the number is: "<<b;
}

...........................................................................................................................................................................................................................................................................................

...........................................................................................................................................................................................................................................................................................

6. (4 คะแนน) จงหำผลรันของโปรแกรมต่อไปนี้ เมื่อป้อนข้อมูลตำมนี้ (ตัวอักษรเข้ม คือ ค่ำที่รับผ่ำนทำงแป้นพิมพ์)


Enter table a:
Please enter an integer: 1 2 3 4 5
Enter table b:
Please enter an integer: 6 7 8 9 10
#include <iostream>
using namespace std;
const int N=5;
int main()
{
int a[N],b[N],c[2*N],i;
cout << "Enter table a:" << endl;
cout << "Please enter an integer: ";
for (i=0;i<N;i++)
{
cin >> a[i];
}
cout << "Enter table b:" << endl;
cout << "Please enter an integer: ";
for (i=0;i<N;i++)
{
cin >> b[i];
}
for (i=0;i<N;i++) c[i]=a[i];
for (i=0;i<N;i++) c[i+N]=b[i];
cout << "Table c:" << endl;
for (i=0;i<2*N;i++)
cout << c[i] << " ";
cout << endl;
return 0;
}

...........................................................................................................................................................................................................................................................................................

...........................................................................................................................................................................................................................................................................................
หน้ าที่ 6 / 11
ชื่อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที่นงั่ สอบ ______

7. (12 คะแนน) จงเขียนโปรแกรมภำษำ C++ ในกำรรับค่ำจำนวนเต็ม 5 จำนวน เข้ำไปใน Array จำกนั้นให้โปรแกรม


แสดงผลลัพธ์ว่ำ Array นั้น มีลักษณะเป็นแบบใดแบบหนึ่ง ดังนี้
 This array is increasing
 This array is decreasing
ตัวอย่ำงผลรัน (ตัวอักษรเข้ม คือ ค่ำที่รับผ่ำนทำงแป้นพิมพ์)

Please enter an integer: 1 Please enter an integer: 5

Please enter an integer: 2 Please enter an integer: 4

Please enter an integer: 3 Please enter an integer: 3

Please enter an integer: 4 Please enter an integer: 2

Please enter an integer: 5 Please enter an integer: 1


This array is increasing. This array is decreasing.

หน้ าที่ 7 / 11
ชื่อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที่นงั่ สอบ ______

6. (6 คะแนน) จงหำผลรันของส่วนของโปรแกรมต่อไปนี้ เมื่อผู้ใช้ใส่ 5 และ 3 ตำมลำดับผ่ำนทำงแป้นพิมพ์


int r,c, n = 1;
cout << "Enter array size (row,col): ";
cin >> r >> c;
int a[r][c];
for(int i = 0; i < r; i++)
{
for(int j = 0; j < c; j++)
{
a[i][j] = n++;
}
}
for(int col = 0; col < c; col++)
{
for(int row = 0; row < r; row++)
{
cout << a[row][col] << " ";
}
cout << endl;
}

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

7. (4 คะแนน) จงหำผลรันของส่วนของโปรแกรมต่อไปนี้
int a[16] = {1,2,3,1,1,2,3,2,1,2,3,3,1,2,3,4};
for(int x = 1; x <= 4; x++)
{
for(int i = 0; i < 16; i++)
{
if(a[i] == x) cout << i << " ";
}
cout << endl;
}

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

หน้ าที่ 6 / 11
ชื่อ-สกุล ____________________________ รหัสนักศึกษา ________________ section ______ เลขที่นงั่ สอบ ______

__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __

8. (10 คะแนน) คณะวิศวกรรมศำสตร์ได้ทำกำรจัดห้องสอบ โดยแต่ละห้องมีทั้งหมด 8 คอลัมน์ และแต่ละคอลัมน์มี


ทั้งหมด 10 ที่นั่ง แต่เพรำะว่ำกำแพงห้องบำงห้องนั้นมีเสำยื่นออกมำมำกเกินไปหรือมีเสำอยู่กลำงห้อง ทำให้เสำ
เหล่ำนั้นกินที่นั่งไปเสำละ 1 ที่นั่ง (ไม่สำมำรถจัดให้นั่งได้) แต่ละห้องจะมีเสำที่มีปัญหำจำนวน 2 เสำเสมอ
ให้นักศึกษำเขียนโปรแกรมเพื่อวำงผังที่นั่งสอบให้กับแต่ละห้อง โดยทำกำรสร้ำงอะเรย์ 2 มิติขึ้นมำเพื่อเก็บแผนผัง
ว่ำที่ตำแหน่งใดมีเสำบ้ำง โดยให้โปรแกรมรับข้อมูลเสำของห้องมำจำกผู้ใช้ผ่ำนทำงแป้นพิมพ์ (เบอร์แถวเริ่มจำก 1
ถึง 10 และเบอร์คอลัมน์เริ่มจำก 1 ถึง 8 – นศ ไม่ต้องเขียนโปรแกรมเพื่อตรวจสอบควำมถูกต้องของอินพุต เรำจะ
กำหนดให้ผู้ใช้ใส่ข้อมูลเข้ำมำถูกต้องเสมอ) ถ้ำตำแหน่งใดสำมำรถจัดที่นั่งได้ ค่ำสมำชิกของอะเรย์ในตำแหน่งนั้นจะ
เป็น 1 แต่ถ้ำตำแหน่งใดไม่สำมำรถจัดได้ ค่ำสมำชิกของอะเรย์ในตำแหน่งนั้นจะเป็น 0 จำกนั้นให้แสดงผลของอะ
เรย์ออกทำงจอภำพ ดังตัวอย่ำงข้ำงล่ำงนี้
ตัวอย่ำงผลรันที่ 1 (ตัวหนำคืออินพุตจำกผู้ใช้) ตัวอย่ำงผลรันที่ 2 (ตัวหนำคืออินพุตจำกผู้ใช้)
1st Bad pole (row,col): 4 6 1st Bad pole (row,col): 1 1

2nd Bad pole (row,col): 5 1 2nd Bad pole (row,col): 10 8

1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0

หน้ าที่ 7 / 11

You might also like