Results 1 to 3 of 3
Thread: ++
Hybrid View
-
3rd December 2010 22:47 #1Registered User
Join Date: Oct:2010
Location: Varna
Posts: 4
++
,,, . search_1 . . 10 , - 10 . .
.
. , . . .
#include <stdio.h>
#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;
const int N=100;
typedef struct
{
char Personal_No[10];
char Name[10];
char Surname[10];
char Section[10];
float Salary;
}civil;
civil input();
int menu();
void output(civil *p);
void search_1(civil cv[],int n);
void search_2(civil cv[],int n);
void main()
{
int choice,n,i,br;
civil cv[N],*ps=NULL;
do {
cout<<"\n Please enter the number of persons at the firm (no more than 100 persons): ";
cin>>n;
} while(n<1 || n>100);
for(i=br=0;i<n;i++)
{
cout<<"Person "<<(i+1)<<":";
cv[i]=input();
}
do {
choice=menu();
switch(choice)
{
case 1:search_1(cv, n);break;
case 2:search_2(cv, n);break;
case 3:break;
default:cout<<"\n Wrong choice!!!Try again.";
}
} while(choice!=3);
}
civil input()
{
civil a={0};
cout<<"\n Personal No: ";
cin>>a.Personal_No;
cout<<"\n Name: ";
cin>>a.Name;
cout<<"\n Surname: ";
cin>>a.Surname;
cout<<"\n Section: ";
cin>>a.Section;
cout<<"\n Salary: ";
cin>>a.Salary;
fflush(stdin);
return(a);
}
void output(civil *p)
{
cout<<p->Personal_No<<"\t";
cout<<p->Name<<" "<<p->Surname<<"\t";
cout<<p->Section<<"\t";
cout<<p->Salary<<endl;
}
void search_1(civil cv[],int n)
{
char nom[10];
cout<<"\n Please enter Personal No. to search: \n";
fflush(stdin);
gets(nom);
for(int i=0;i<n;i++)
if(!strcmp(cv[i].Personal_No,nom))
output(&cv[i]);
}
void search_2(civil cv[],int n)
{
long int min,max;
cout<<"\n Please enter salary range to search: \n";
cin>>min;
cin>>max;
for(int i=0;i<n;i++)
if(cv[i].Salary>=min || cv[i].Salary<=max)
output(&cv[i]);
}
int menu()
{
int ch;
cout<<"\n Choose one of following choices \n";
cout<<"\n 1.Search person by Personal No ";
cout<<"\n 2.Search persons by Salary Range ";
cout<<"\n 3.Exit ";
cout<<"\n Your choice is: ";
cin>>ch;
return ch;
}
-
3rd December 2010 23:16 #2Registered User
Join Date: Oct:2003
Location:
Posts: 4,317
. C NULL. , 11 . , ?
-
3rd December 2010 23:51 #3Registered User
Join Date: Oct:2010
Location: Varna
Posts: 4
!!! . [10] [11] . ., .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in