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

". " ע"י אופרטור ? ( שבמבנה members) איך ניגש לשדות #define MAX_L 100 struct student{ int id; char name[MAX_L]; double avg; }; student s 1 = {123456, ”Danny”, 100}; int main() { struct 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() { struct student s 1 = {123456, ”Danny”, 100}; {123456, ”Danny”, 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 }

: סימון מקוצר <- נשתמש באופרטור (*s 1). avg במקום struct student* get. Better.

: סימון מקוצר <- נשתמש באופרטור (*s 1). avg במקום struct student* get. Better. Student(struct student *s 1, struct student *s 2) { if (s 1 ->avg > s 2 ->avg) if > (*s 2). avg) // ((*s 1). avg if ((*s 1). avg > (*s 2). avg) return s 1; return s 2; } . © כל הזכויות שמורות. נכתב ע"י יעל ארז 10

#define MAX_L 100 struct student{ int id; char name[MAX_L]; double avg; }; int main()

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

#define MAX_L 100 struct student{ int id; char name[MAX_L]; double avg; }; int main()

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

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

int cmp. Students(struct student* s 1, struct 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; . © כל הזכויות שמורות. נכתב ע"י יעל ארז } 13