JPG int main int width image width in

  • Slides: 13
Download presentation

JPG דחיסת תמונה בפורמט int main() { int width; // image width in pixels

JPG דחיסת תמונה בפורמט int main() { int width; // image width in pixels int height; // image height in pixels char num. Of. Comp; // 1=grayscale, 3=rgb char sampling. Factor 1; // sampling factor 1 char sampling. Factor 2; // sampling factor 2 char sampling. Factor 3; // sampling factor 3 char* data; // the compressed data. . . return 0; }. © כל הזכויות שמורות. נכתב ע"י יעל ארז 3

 שם המבנה members struct jpg{ int width; // image width in pixels int

שם המבנה members struct jpg{ int width; // image width in pixels int height; // image height in pixels char num. Of. Comp; // 1=grayscale, 3=rgb char sampling. Factor 1; // sampling factor 1 char sampling. Factor 2; // sampling factor 2 char sampling. Factor 3; // sampling factor 3 char* data; // the compressed data }; struct date{ char day; char month; int year; }; struct student{ int id; char name[MAX_L]; double avg; . © כל הזכויות שמורות. נכתב ע"י יעל ארז 5 };

#define MAX_L 100 #define NUM_OF_STUDENTS 200 struct student{ int id; char name[MAX_L]; double avg;

#define MAX_L 100 #define NUM_OF_STUDENTS 200 struct student{ int id; char name[MAX_L]; double avg; }; . נוצר טיפוס חדש , לאחר ההכרזה על מבנה int main() struct. . . return } { student s 1, s 2, s 3; student s[NUM_OF_STUDENTS]; 0; . © כל הזכויות שמורות. נכתב ע"י יעל ארז 6

". " ( שבמבנה? ע"י אופרטור members) איך ניגש לשדות #define MAX_L 100 struct

". " ( שבמבנה? ע"י אופרטור members) איך ניגש לשדות #define MAX_L 100 struct student{ int id; char name[MAX_L]; double avg; }; student s 1 = {123456, ”Danny”, 100}; int main() { student s 1; s 1. id = 12345678; strcpy(s 1. name, “Danny”); s 1. avg = 100; return 0; . © כל הזכויות שמורות. נכתב ע"י יעל ארז 7 }

#define MAX_L 100 struct date{ " היא. " הקדימות של אופרטור int day, month,

#define MAX_L 100 struct date{ " היא. " הקדימות של אופרטור int day, month, year; . () כמו - הגבוהה ביותר }; struct student{ האסוציאטיביות היא משמאל int id; . לימין char name[MAX_L]; double avg; struct date. Of. Birth; }; int main() { student s 1 == {123456, ”Danny”, 100}; 100, {31, 12, 2000}}; s 1. date. Of. Birth. day = 31; s 1. date. Of. Birth. month = 12; s 1. date. Of. Birth. year = 2000; . © כל הזכויות שמורות. נכתב ע"י יעל ארז return 0; 8 }

#define MAX_L 100 struct date{ int day, month, year; }; struct student{ int id;

#define MAX_L 100 struct date{ int day, month, year; }; struct student{ int id; char name[MAX_L]; double avg; struct date. Of. Birth; }; int main() { student s 1 = {123456, ”Danny”, 100, {31, 12, 2000}}; student s 2 = s 1; if (s 1 == s 2){ s 2 = !s 1; s 2 += 1; } return 0; . © כל הזכויות שמורות. נכתב ע"י יעל ארז } x 11

#define MAX_L 100 struct date{ int day, month, year; }; struct student{ int id;

#define MAX_L 100 struct date{ int day, month, year; }; struct student{ int id; char name[MAX_L]; double avg; struct date. Of. Birth; }; int main() { student s 1 = {123456, ”Danny”, 100, {31, 12, 2000}}; student s 2 = s 1; if (!cmp. Student(&s 1, &s 2)) printf(“identical!n”); return 0; } . © כל הזכויות שמורות. נכתב ע"י יעל ארז 12

int cmp. Students(student* s 1, student* s 2){ if (s 1 ->id < s

int cmp. Students(student* s 1, student* s 2){ if (s 1 ->id < s 2 ->id) return 1; else if (s 1 ->id > s 2 ->id) return -1; int res = strcmp(s 1 ->name, s 2 ->name); if (res) return res; if (s 1 ->avg > s 2 ->avg) return 1; else if (s 1 ->avg < s 2 ->avg) return -1; return 0; // ignore the date in this function. © כל הזכויות שמורות. נכתב ע"י יעל ארז } 13