#include "stdafx.h" #include <conio.h> #define N 3 typedef struct { char name[25]; int tel[15]; int bday[3]; } NOTE; void setValue(NOTE blockNote[N]); void printValue(NOTE blockNote[N]); int _tmain(int argc, _TCHAR* argv[]) { NOTE blockNote[N]; setValue(blockNote); printValue(blockNote); return 0; } void setValue(NOTE blockNote[N]) { for(int i=0; i<N; i++) { printf("Enter name: "); gets_s(blockNote[i].name); printf("Enter tel: "); printf("%d", &blockNote[i].tel); printf("Enter bday (format: day.month.year): "); scanf_s("%d.%d.%d", &blockNote[i].bday[0], &blockNote[i].bday[1], &blockNote[i].bday[2]); printf("---\n"); } } void printValue(NOTE blockNote[N]) { for(int i=0; i<N; i++) printf("name: %s tel: %d bday: %d.%d.%d\n", blockNote[i].name, blockNote[i].tel, blockNote[i].bday[0], blockNote[i].bday[1], blockNote[i].bday[2]); }
Stack Overflow на русском
регистрация войти
#include "stdafx.h" #include <conio.h> #define N 3 typedef struct { char name[25]; int tel[15]; int bday[3]; } NOTE; void setValue(NOTE blockNote[N]); void printValue(NOTE blockNote[N]); int _tmain(int argc, _TCHAR* argv[]) { NOTE blockNote[N]; setValue(blockNote); printValue(blockNote); return 0; } void setValue(NOTE blockNote[N]) { for(int i=0; i<N; i++) { printf("Enter name: "); gets_s(blockNote[i].name); printf("Enter tel: "); printf("%d", &blockNote[i].tel); printf("Enter bday (format: day.month.year): "); scanf_s("%d.%d.%d", &blockNote[i].bday[0], &blockNote[i].bday[1], &blockNote[i].bday[2]); printf("---\n"); } } void printValue(NOTE blockNote[N]) { for(int i=0; i<N; i++) printf("name: %s tel: %d bday: %d.%d.%d\n", blockNote[i].name, blockNote[i].tel, blockNote[i].bday[0], blockNote[i].bday[1], blockNote[i].bday[2]); }
name,m_name:string;
begin
readln(n);
max:=0; min:=5000;
for i:=1 to n do
begin
readln(name);
readln(pi,ti);
if pi>max
then begin m_name:=name; max:=pi; min:=ti; end
else if pi=max
then if ti<min then begin m_name:=name; max:=pi; min:=ti; end;
end;
writeln(m_name);
end.
Пример:
4
John
10 123
Ringo
10 144
George
11 156
Paul
11 160
George