Data structure 4-15/07/52

วันอังคารที่ 21 กรกฎาคม พ.ศ. 2552

สรุปประโยชน์ที่รับจากการเขียนโปรแกรมคอมพิวเตอร์ประเภทลิงค์ลิส
1.ได้ความรู้เกี่ยวกับโครงสร้างข้อมูลแบบลิงค์ลิสต์
2.ได้ความรู้เกี่ยวกับกระบวนงานและฟังก์ชั่นที่ใช้ดำเนินงานพื้นฐานโครงสร้างข้อมูลแบบลิงค์ลิสต์
3.สามารถนำความรู้ที่้ได้ศึกษาการสร้างลิงค์ลิสต์มาประยุกต์ใช้ในการเขียนโปรแกรมได้
4.สามารถสร้างโครงสร้างข้อมูลลิงค์ลิสต์แบบซับซ้อนได้

ตัวอย่างการเปรียบเทียบโครงสร้างโปรแกรมภาษา C กับ โปรแกรมภาษา C++
Ex โปรแกรมภาษาC
/*Program by Jormpon:Do not copy*/
/*Body Mass index*/
#include"stdio.h"
main()
{
float weight,height;
float bmi;
printf("Enter your weight (Kg): ");
scanf("%f",&weight);
printf("Enter your height (Metre): ");
scanf("%f",&height);

bmi=weight/(height*height);

if (bmi>40)
{
printf("Your Body Mass Index is %.3f\n",bmi);
printf("You are Morbidly obese.\n\n\n\n");
printf("By Jormpon");
}
else if (bmi>=27)
{
printf("Your Body Mass Index is %.3f\n",bmi);
printf("You are Obese.\n\n\n\n");
printf("By Jormpon");
}
else if (bmi>=23)
{
printf("Your Body Mass Index is %.3f\n",bmi);
printf("You are Overweight.\n\n\n\n");
printf("By Jormpon");
}
else if (bmi>=18)
{
printf("Your Body Mass Index is %.3f\n",bmi);
printf("You are Normal.\n\n\n\n");
printf("By Jormpon");
}
else if (bmi>=15)
{
printf("Your Body Mass Index is %.3f\n",bmi);
printf("You are Underweight.\n\n\n\n");
printf("By Jormpon");
}
else
{
printf("Your Body Mass Index is %.3f\n",bmi);
printf("You are Starvation.\n\n\n\n");
printf("By Jormpon");
}
}


Ex โปรแกรมภาษา C++
/*Program by Jormpon:Do not copy*/
/*Body Mass index*/
#include"iostream.h"
#include"iomanip.h"
main()
{
float weight,height;
float bmi;

cout<<"Enter your weight (Kg): "; cin>>weight;
cout<<"Enter your height (Metre): "; cin>>height;

bmi=weight/(height*height);

if (bmi>40)
{
cout<<"Your Body Mass Index is : "<<>=27)
{
cout<<"Your Body Mass Index is : "<<>=23)
{
cout<<"Your Body Mass Index is : "<<>=18)
{
cout<<"Your Body Mass Index is : "<<>=15)
{
cout<<"Your Body Mass Index is : "<< setprecision(5)<< bmi;
cout<<"\nYou are Underweight.";
cout<<"\n\n\n\nBy Jormpon";
}
else
{
cout<<"Your Body Mass Index is : "<< setprecision(5)<< bmi;
cout<<"\nYou are Starvation.";
cout<<"\n\n\n\nBy Jormpon";
}
}

0 ความคิดเห็น: