struct student char name 21 long int stdno

  • Slides: 22
Download presentation

 ﻣﺜﺎﻝ struct student { char name [21]; long int stdno; float score; };

ﻣﺜﺎﻝ struct student { char name [21]; long int stdno; float score; }; struct student a, b;

 ﺍﻋﺪﺍﺩ ﻣﺨﺘﻠﻂ int main() { struct complex { float real, imag; }; struct

ﺍﻋﺪﺍﺩ ﻣﺨﺘﻠﻂ int main() { struct complex { float real, imag; }; struct complex a, b, c; scanf ("%f %f", &a. real, &a. imag); scanf ("%f %f", &b. real, &b. imag); c. real = a. real + b. real; c. imag = a. imag + b. imag; printf ("%. 1 f + %. 1 f i", c. real, c. imag); }

 ﻧﻤﺎﻳﺶ ﻋﻠﻤی ﻋﺪﺩ int main() { struct snum { float m; int n;

ﻧﻤﺎﻳﺶ ﻋﻠﻤی ﻋﺪﺩ int main() { struct snum { float m; int n; }; struct snum a, b, c; int i; scanf ("%f %d", &a. m, &a. n); scanf ("%f %d", &b. m, &b. n);

 ﺍﺻﻼﺡ ﻳک ﺳﺎﺧﺘﺎﺭ int main() { struct student { char name [21]; long

ﺍﺻﻼﺡ ﻳک ﺳﺎﺧﺘﺎﺭ int main() { struct student { char name [21]; long int stdno; float score; }; struct student s[100]; int n, i;

 ﻣﺮﺗﺐ ﺳﺎﺯی ﺳﺎﺧﺘﺎﺭﻫﺎ struct student { char name [21]; long int stdno; float

ﻣﺮﺗﺐ ﺳﺎﺯی ﺳﺎﺧﺘﺎﺭﻫﺎ struct student { char name [21]; long int stdno; float score; }; void sort ( struct student s [ ] , int n ) { int i, j; struct student temp;

 ﻣﺮﺗﺐ ﺳﺎﺯی ﺳﺎﺧﺘﺎﺭ ﻫﺎ int main() { struct student s[100]; int n, i;

ﻣﺮﺗﺐ ﺳﺎﺯی ﺳﺎﺧﺘﺎﺭ ﻫﺎ int main() { struct student s[100]; int n, i; scanf ("%d", &n); for (i = 0; i < n; i++) { scanf ("%ld n", &s[ i ]. stdno); gets ( s[ i ]. name ); } sort ( s , n ); for (i = 0; i < n; i++) puts ( s[ i ]. name ); }

 ﺳﺎﺧﺘﺎﺭ ﻣﺘﺪﺍﺧﻞ ﻭ ﺳﺎﺧﺘﺎﺭی ﺍﺯ آﺮﺍﻳﻪ struct date { int year; int month;

ﺳﺎﺧﺘﺎﺭ ﻣﺘﺪﺍﺧﻞ ﻭ ﺳﺎﺧﺘﺎﺭی ﺍﺯ آﺮﺍﻳﻪ struct date { int year; int month; int day; }; struct clerk { char name [51]; int hours [ 12 ] ; struct date birthday; }

 ﺳﺎﺧﺘﺎﺭ ﻭ ﻓﺎﻳﻞ ﺑﺎﻳﻨﺮی : ﻣﺜﺎﻝ struct student { char name[21]; long int

ﺳﺎﺧﺘﺎﺭ ﻭ ﻓﺎﻳﻞ ﺑﺎﻳﻨﺮی : ﻣﺜﺎﻝ struct student { char name[21]; long int stdno; float score; }; int main() { struct student s; int n, i; FILE *f;

 ﺳﺎﺧﺘﺎﺭ ﻭ ﻓﺎﻳﻞ ﺑﺎﻳﻨﺮی : ﻣﺜﺎﻝ scanf %")d", &n; ( f = fopen("db.

ﺳﺎﺧﺘﺎﺭ ﻭ ﻓﺎﻳﻞ ﺑﺎﻳﻨﺮی : ﻣﺜﺎﻝ scanf %")d", &n; ( f = fopen("db. bin", "wb; ("+ for (i = 0; i < n; i(++ } scanf ("%f", &s. score; ( scanf ("%d n", &s. stdno; ( gets ( s. name; ( fwrite(&s, sizeof(struct student), 1, f; ( {

 ﺳﺎﺧﺘﺎﺭ ﻭ ﻓﺎﻳﻞ ﺑﺎﻳﻨﺮی : ﻣﺜﺎﻝ rewind(f); while (!feof(f)) { fread(&s, sizeof(struct student),

ﺳﺎﺧﺘﺎﺭ ﻭ ﻓﺎﻳﻞ ﺑﺎﻳﻨﺮی : ﻣﺜﺎﻝ rewind(f); while (!feof(f)) { fread(&s, sizeof(struct student), 1, f); if (s. stdno == 87654321) break; } puts ( s. name ); }