1 / 11

درس برنامه ‌ سازي کامپيوتر

درس برنامه ‌ سازي کامپيوتر. ساختمان ‌ ها در زبان برنامه ‌ سازي C++. ساختمان Structure. در بسياري کاربردها با داده ‌ هايي سر و کار داريم که از يک جنس نيستند قالب يکنواختي ندارند ابعاد مشابهي ندارند مربوط به يک موضوع مشخص مي ‌ شوند

kory
Download Presentation

درس برنامه ‌ سازي کامپيوتر

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. درس برنامه‌سازي کامپيوتر ساختمان‌ها در زبان برنامه‌سازي C++

  2. ساختمان Structure • در بسياري کاربردها با داده‌هايي سر و کار داريم که • از يک جنس نيستند • قالب يکنواختي ندارند • ابعاد مشابهي ندارند • مربوط به يک موضوع مشخص مي‌شوند • بسيار مناسب است اگر بتوان مجموعة اين داده‌ها را تحت يک عنوان معرفي نمود

  3. مثال • اطلاعات مورد نياز براي يک دانشجو را در يک کاربرد خاص در نظر بگيريد • نام (و نام خانوادگي) • نام پدر • شمارة شناسنامه • وزن، قد، ... • واحدهاي اخذ شده • نمرات : واحدها، معدل • رتبه در ميان هم‌دوره‌ايها • ...

  4. مثال • انبار کالا • نام کالا • شمارة کالا (بارکد، شمارة انبار، ...) • منبع (خريد) : قيمت خريد، فروشنده، حمل ونقل کننده، سفارش دهنده، زمان ورود به انبار • وضعيت فعلي : محل انبار شده، هزينة انبارداري تا کنون، ... • مقصد : تحويل گيرنده، قيمت فروش، زمان ارسال، نحوة ارسال

  5. مثال • اطلاعات مربوط به • يک فايل کامپيوتري • بيمار (مطب، بيمارستان، اورژانس، ...) • مسابقه • فروشگاه • محصول توليدي (در حال توليد) • پروژة تحقيقاتي

  6. روش تعريف ساختمان • struct student{ • char name[31]; • intidnumber; • intentry_year; • char major[21];} • struct student a, b[35];

  7. مثال • struct student{ • char name[31]; • intidnumber; • intentry_year; • char major[21];} a, b[35]; • نحوة استفاده به عنوان متغير • struct student z={“ali”, 3761, 85,”electrical”}; • struct student y={“”}; • struct student z={‘\0’, 0}; • a.name[3]=‘w’; b[17].idnumber=8471 • b[1]=a;

  8. مثال • enum majors{electrical, mechanical, civil, • chemical, computer}; • struct date { int day; int month; int year}; • structemp{ char name[31]; • intidnum; • enum majors major; • struct date reg_date; • struct date birth_date; • } prog_class[60];

  9. ساختمان و اشاره‌گرها • struct bal{float balance; char name[26];} p1, p2, *pp; • pp=&p1; • (*pp).balance=12.5; • p2 -> balance=73.6;

  10. ساختمان بيتي • structdevice_par { • unsigned ready : 1; • unsigned type : 2; • unsigned flag : 1; • } dev_par; • dev_par.ready=0; • dev_par.type=3;

  11. typedef • typedef unsigned inttabiei; • typedef unsigned char byte; • typedef char string60[61]; • typedefstruct {double re, im} complex; • tabiei a, b; • string60 r1, r2; • complex z={3, 4}; • byte u=5;

More Related