![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Регистрация: 03.06.2013
Сообщений: 4
|
![]()
#include "stdafx.h"
#include "stdafx.h" #include "stdio.h" #include "windows.h" #include "math.h" #include <fstream> struct stud { char fio[50]; int vozrast; char pol;}; struct stud make(char *fio, int vozrast,char pol) {struct stud p; p.vozrast=vozrast; p.pol=pol; strcpy(p.fio,fio); return p;} void printstud(struct stud s) {printf("%s\n %d\n %c\n \n",s.fio,s.vozrast,s.pol);} void sortirovka(struct stud p[], int c) { int a, b; struct stud t; for(a=1; a<c; ++a) for(b=c-1; b>=a; --b) {if(strcmp(p[b-1].fio,p[b].fio)>0) {t=p[b-1]; p[b-1]=p[b]; p[b]=t;}}} void printstud(struct stud p[],int size) {int i=0; for(i=0;i<=size-1;i++) printstud(p[i]);} void dobavlenie(char* fname,struct stud st) {FILE *f; f=fopen(fname,"ab"); fwrite(&st,sizeof(struct stud),1,f); fclose(f);} struct stud* podschet(char* fname,int *schet) { int i=0,g; struct stud s; FILE *f; f=fopen(fname,"rb"); do{fread(&s,sizeof(struct stud),1,f); \\За что отвечает строка if (!feof(f)) i++;} while(!feof(f)); rewind(f); struct stud* t=(struct stud *)malloc(sizeof(struct stud)*i);\\За что отвечает строка g=i; for(i=0;i<g;i++) fread(&t[i],sizeof(struct stud),1,f);\\За что отвечает строка *schet=g; fclose(f); return t;} int _tmain(int argc, _TCHAR* argv[]) { int schet; struct stud *st=podschet("stud.bin",&schet); printstud(st,schet); sortirovka(st,schet); printstud(st,schet); FILE *fm; fm=fopen("stud.bin","wb"); fclose(fm); dobavlenie("stud,bin",make("Antonen ko Ilya",18,'m')); dobavlenie("stud,bin",make("Akishev a Yana",18,'w')); dobavlenie("stud,bin",make("Podolya k Misha",19,'m')); dobavlenie("stud,bin",make("Kazimov a Nargis",17,'w')); podschet("stud.bin",&schet); struct stud *st=podschet("stud.bin",&schet); printstud(st,schet); system("pause"); return 0; } |
![]() |
![]() |
![]() |
#2 |
Старожил
Регистрация: 30.12.2009
Сообщений: 11,434
|
![]() Код:
Код:
Код:
|
![]() |
![]() |
![]() |
#3 |
Участник клуба
Регистрация: 30.07.2008
Сообщений: 1,606
|
![]()
Во вложении
"SPACE.THE FINAL FRONTIER.This's a voyage of starship Enterprise. It's 5-year mission to explore strange new worlds,to seek out new life and civilizations,to boldly go where no man has gone before"
|
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Объясните действия выполненные в программе | Максим 89 | C# (си шарп) | 0 | 10.06.2013 00:48 |
объясните Что означает ANS в этой программе | Азамат1 | Паскаль, Turbo Pascal, PascalABC.NET | 3 | 21.05.2013 14:40 |
Объясните пару строчек в этой программе | vierumk | C# (си шарп) | 7 | 28.08.2012 15:48 |
объясните что означает значение 255 и 2 ? | klepan | Помощь студентам | 1 | 02.02.2010 17:09 |
Объясните, что значит каждая строка в программе | *natali* | Помощь студентам | 5 | 07.11.2009 15:17 |