In: Computer Science
QUESTİON 2-HOMEWORK1 QUESTİON
experienced and beginner officers at a police station.While
preparing the guard of roster,
Two-person patrols consisting of an experienced and a beginner will
be identified.Every experienced officer must keep watch with all
beginner officers.
the number of officers entered on the keyboard (up to 30) and
according to the registration numbers of the officers.
Write the c ++ program, which writes the registration numbers
and patrol guard lists of the beginner and experienced officers, in
accordance with the prototype given in the options.
NOTE:
The registration numbers of experienced officers are odd and the
registration numbers of novice officers are double.
It is assumed that at least one experienced and a beginner
registration number will be entered from the keyboard.
EXAMPLE:
enter the number of officers:6
Enter the registration numbers of 6 officers:
18 25 28 13 296 160
registration numbers of beginner officers:18, 28,296,160
registration numbers of experienced officers:25,13
watch list:
25-18
25-28
25-296
25-160
13-18
13-28
13-296
13-160
QUESTİON2 You see the prototype at the bottom in the order of
the function.
List of registration numbers sent from the main functions and in
the main function takes the number of officers entered from the
keyboard as parameters
Prints the above screen output in the function.
void deneyimliAcemiAyirarakYaz(int sicil[],int memurSayisi);
HOMEWORK1 you saw the prototype at the bottom List of registration
number sent from the main
in order of function,officer count,experienced and beginner worker
gets the empty list.
void deneyimliAcemiAyir(int *,int memurSayisi,int *,int *);
function fills empty lists.Results must be printed in the main function.
.
//Required c++ program for first question:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,x;
cout<<"Enter the number of officers:
";
cin>>n;
cout<<"Enter the regustration numbers of
"<<n<<" officers: ";
vector<int>exp,beg; //creating vectors for
both type of officers
for(int i=0;i<n;i++){
cin>>x; //taking
input reg. no.
if(x%2==0){ //if even
pushing in beg vector
beg.push_back(x);
} else { //if odd
pushing in exp vector
exp.push_back(x);
}
}
//Printing the two lists
cout<<"Registration numbers of beginner
officers: ";
for(int i=0;i<beg.size();i++){
cout<<beg[i]<<" ";
}
cout<<endl;
cout<<"Registration numbers of experienced
officers: ";
for(int i=0;i<exp.size();i++){
cout<<exp[i]<<" ";
}
cout<<endl;
cout<<"Watch List:"<<endl;
//printing watch list
for(int i=0;i<exp.size();i++){ //looping in
experienced officers
for(int
j=0;j<beg.size();j++){ //looping in beginner officers
cout<<exp[i]<<"-"<<beg[j]<<endl;
}
}
return 0;
}
Please refer to the screenshot of the code to understand the indentation of the code
Sample Run:
Hope this helped. Please do upvote and if there are any queries please ask in comments section.