Data Structure
Introduction
ความหมายของโครงสร้างข้อมูลข้อมูล
ข้อมูล(Data)คือข้อเท็จจริงต่างๆซึ่งอาจเป็นตัวเลขหรือไม่เป็นตัวเลขก็ได้
โครงสร้างข้อมูล(Structure)คือความสัมพันธ์ของสมาชิกในกลุ่ม
2.ประเภทของโครงสร้างข้อมูล แบ่งออกเป็น2ประเภทคือ
1.โครงสร้างข้อมูลทางกายภาพ(Physical Data Structure)
2.โครงสร้างข้อมูลทางตรรกะ(Logical Data Structure)
3..การแทนที่ข้อมูลในหน่วยความจำหลัก มีอยู่2วิธีดังนี้
-การแทนที่ข้อมูลแบบ สแตติก(Static Memory Representation)
-การแทนที่ข้อมูลแบบไดนามิก(Dynamic Memory Representation)
4.ขั้นตอนวิธี
ขั้นตอนวิธีที่ดีควรมีคุณสมบัติดังนี้
-มีความถูกต้อง
-ใช้เวลาในการปฏิบัติงานน้อยที่สุด
-สั้น กระชับ มีเฉพาะขั้นตอนที่จำเป็นเท่านั้น
-มีความยืดหยุ่นในการใช้งาน
-ใช้เวลาในการพัฒนาน้อยที่สุด
-ง่ายต่อการทำความเข้าใจ
การบ้าน
#include
#include
void main()
{
struct MyCamera{
char name[10];
char generation[15];
char color[10];
char resolution[20];
float pixels;
float high;
float weight;
float price;
}camera;
strcpy(camera.name,"Canon");
strcpy(camera.generation,"EOS 450D");
strcpy(camera.color,"Black");
strcpy(camera.resolution,"4272 x 2848");
camera.pixels=12.2;
camera.high=129;
camera.weight=524;
camera.price=27900;
printf("###########################\n");
printf("###### MY CAMERA ######\n");
printf("###########################\n\n");
printf("Name:\t\t%s\n\n",camera.name);
printf("Generation:\t%s\n\n",camera.generation);
printf("Color:\t\t%s\n\n",camera.color);
printf("Resolution:\t%s\n\n",camera.resolution);
printf("Pixels:\t\t%.1f million\n\n",camera.pixels);
printf("High:\t\t%.2f\n\n",camera.high);
printf("Weight:\t\t%.2f\n\n",camera.weight);
printf("Price:\t\t%.2f\n\n",camera.price);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น