Programming

Just another WordPress.com weblog

ประวัติเอกสารจากหมวดหมู่ ‘CT211’

ข้อสอบ CT211 – ข้อ 3 ตรวจตัวเลขที่ซ้ำ (ปี 2008)

แสดงความเห็นโดย จั่น บน กรกฎาคม 16, 2008

จงเขียน flow diagram

ให้สามารถใส่ตัวเลขตั้งแต่ 1ถึง 20 ได้ โดยใส่ตัวเลขได้อย่างมากสุด 20 ตัวเลข หากใส่ตัวเลขที่ไม่อยู่ในช่วงระหว่าง 1ถึง 20 หรือใส่ตัวเลขเกิน 20 ตัว โปรแกรมจะออกจากการทำงาน และพิมพ์ค่าเฉพาะตัวเลขที่ซ้ำออกทางหน้าจอ

เขียนแล้วใน CT211, Programming | Leave a Comment »

ข้อสอบ CT211 – ข้อ 2 หาจำนวนปีที่เงินฝากจะกลายเป็น 2 เท่า(ปี 2008)

แสดงความเห็นโดย จั่น บน กรกฎาคม 16, 2008

จงเขียน flow diagram สำหรับคำนวณหาจำนวนปีที่ใช้เมื่อฝากเงินต้นจำนวนหนึ่งแล้วต้องการให้เงินต้นที่ฝากนั้นมีค่ามากกว่าหรือเท่ากับ 2 เท่า คิดดอกเบี้ยทบต้นในแต่ละปี โดยรับ input 2 ค่า คือ เงินต้น และอัตราดอกเบี้่ย

เขียนแล้วใน CT211, Programming | Leave a Comment »

CT211-พิมพ์สูตรคุณแม่ 2 ถึงแม่ 12 ออกทางหน้าจอ

แสดงความเห็นโดย จั่น บน กรกฎาคม 14, 2008

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){

for(int i=2; i<=12; i++){

for(int j=1; j<=12; j++){

cout << i << “*” << j << ” = ” << i*j << “\n”;

if(j == 12){

cout << “\n”;

}

}

}

getch();

}

เขียนแล้วใน CT211, Programming | Leave a Comment »

CT211-หาเซตผลลัพธ์ A Union B และ A Intersects B

แสดงความเห็นโดย จั่น บน กรกฎาคม 14, 2008

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

clrscr();

int i = 0, j = 0;
int a[5] = {1,2,3,5,7};
int b[7] = {2,4,5,6,7,8,9};
char ma[5] = {‘0′,’0′,’0′,’0′,’0′};

//Find position of each element of Set A that match
//element of Set B
for(i=0; i<5; i++){

j = 0;

while(j < 6 && a[i] != b[j]){

j++;

}

if(a[i] == b[j]){

ma[i] = ‘1′;

}

}

//Output A Intersects B
cout << “A intersects B = “;

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

if(ma[i] == ‘1′){

cout << a[i] << ” “;

}

}
cout << “\n”;
//End Output A Intersects B

//Output A Union B
cout << “A Union B = “;
//Step 1) Output All elements of Set B
for(j=0; j<7; j++){

cout << b[j] << ” “;

}
//Step 2) Output All elements of Set A
//that is not duplicated with Set B
for(i=0; i<5; i++){

if(ma[i] == ‘0′){

cout << a[i] << ” “;

}

}
//End Output A Union B

getch();

}

เขียนแล้วใน CT211, Programming | Leave a Comment »

CT211-ใส่ค่าใน Matrix 4×4 และรวมตัวเลขในแนว Matrix ซ้ายบนไปขวาล่าง

แสดงความเห็นโดย จั่น บน กรกฎาคม 14, 2008

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){

clrscr();

char comma;
int i = 0, j = 0;
int numrows = 4, numcols = 4;
int sumrow = 0, diagonalsum = 0;
int matrix[4][4] = {
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 10, 11, 12 },
{13, 14, 15, 16 }
};

cout << “Program Calculate Summation of data in matrix”;
cout << “\nOutPut 1) Summation By Each Row”;
cout << “\nOutput 2) Summation By Diagonal”;
cout << “\n———”;
cout << “\nPlease Insert Data In Each Row”;
cout << “\nFor Example”;
cout << “\n1,2,3,4″;
cout << “\n5,6,7,8″;
cout << “\n10,11,12,13″;
cout << “\n14,15,16,17″;
cout << “\n\n”;

//Loop load data from keyboard into 2 dimension array

cout << “Please Insert Input\n”;
cout << “For example\n”;
cout << “1,2,3,4\n”;
cout << “and Press Enter\n”;
cout << “————\n”;
for(i=0; i<numrows; i++){

for(j=0; j<numcols; j++){

cin >> matrix[i][j];

//If it’s the last column, we will not keep comma
if(j <numcols-1){
cin >> comma;
}

}

cout << “\n”;

}

cout << “Output\n———-\n”;

for(i=0; i<numrows; i++){

for(j=0; j<numcols; j++){

sumrow += matrix[i][j];

if(i == j){

diagonalsum += matrix[i][j];

}

}

cout << “Sum Row ” << (i+1) << ” = ” << sumrow << “\n”;
sumrow = 0;

}
cout << “Diagonal Sum = ” << diagonalsum << “\n”;

getch();

}

เขียนแล้วใน CT211, Programming | Leave a Comment »

CT211-C Program คำนวณหาพื้นที่วงกลม,สี่เหลี่ยมผืนผ้า,สี่เหลี่ยมจัตุรัส

แสดงความเห็นโดย จั่น บน กรกฎาคม 14, 2008

#include <stdio.h>

#include <conio.h>

#include <iostream.h>

void main(){

clrscr();

float area;
int m, a, b;

cout << “1.Area of Circle\n2.Area of Rectangular\n3.Area of Square\n99.Stop\n”;
cout << “Press “;
cin >> m;

while(m!=99){

if(m>=1 && m<=3){

switch(m){

case 1:

cout << “\nInput Radius “;

cin >> a;

area = (22.0/7) * a * a;

break;

case 2:

cout << “\nInput Width “;
cin >> a;
cout << “Input Long “;
cin >> b;

area = a * b;

break;

case 3:

cout << “\nInput Width “;
cin >> a;

area = a * a;

break;

default:

break;

}

cout << “Area ” << area << “\n”;

}else{

cout << “Invalid Data. Try again (Choose Integer 1-3 or 99 Exit)\n”;

}

cout << “Press “;
cin >> m;

}

cout << “End Program. Bye :) \n” << “Press Enter to Exit”;
getch();

}

เขียนแล้วใน CT211, Programming | Leave a Comment »