0% found this document useful (0 votes)
36 views

Lecture 4 Single File Programming Question

Uploaded by

syash9457
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
36 views

Lecture 4 Single File Programming Question

Uploaded by

syash9457
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 21
‘Question No: Single File Programming Question Problem Statement You hove an otra of strings and another array of integers. Merge the two arrays such thatthe resulting acay alternates between a sting and an integer. Input format: ‘The fis line of input contains on integer, which reprosents the size ofthe string and integer artoy. ‘The nex line of input contains stings from the sting array, each separated by a space. ‘The lat line of input contains elements of the intager array, cach separated by a space. ‘output format: ‘The output splays the merged array where each elomentis separated by @ space. Refer to the sample output for formatting epecifications. code constraints: 1 stings, itagersze +100 (weximum size of tne roy). ‘he elements ofthe sting ema ean contain alphanumeric charaetre and epecil symbol ‘he elements of teinteger array shouldbe vol integers within he ronge of the int dota ype. stingSiae == ntagersina ample test cave: Input: output: Depte Banana orange orged seray: Apple | Banana 2 orange 2 Input: output 2: $20 vello & world) (cote) rneraed Array: $88 190 Hello 200 & 300 world! 460 (Code) 500 Fill your code here Estat estan Ts patra ee tatee using namespace std; int main () { int size; cot eames es Panes eS emSeS UUyZestZ Cae ese irene tees tr ny ea y Sac ee Teme hectie aes Csee aCe ec one ee ote tns evd eee + Sea mea en UT em to CUR CLi a eee erase See eeO eg De UR ATE eens ESD mergedarray.push_back(to_string(integerArray[i])); CTs) for (int i = 0; i < sizes i++) { terme strug a y vector integerarray(size); for (int i = 03 i < sizes i++) { ieee ves ? Races est eM tected for (int i = 0; 4 < sizes i++) { mergedArray.push_back(stringarray[i])5 mergedarray.push_back(to_string(integerarray[i]))5 Coreen tc ess! Genser eae Ue colt aoe Lad i cr em De ous Comet otsotanes Wf sieueed 9 Tnsscanpies 2 enenutmitas 1 Lal Hard Quutentee Sagemerogammng suet Agente ope Aroyaptinra sub Tope Araygntme —oibone my ABP ‘compiler essa92 sae 9 0 mm 2 Ss serge ro si 10 oon 20 sts 290 ered ery One 180 To 209 Tree 300 Fur 80 Five 50 Six 6B ered ery: One 180 To 200 Tree 200 Fur sb Five 50 x 6 ‘rere tray Hell6 260 rll 290 ow 308 re 49 You! 360 Solution 1 pas eres PUrstreeesty te roar elon ee a ae. ey oT CHEST ees tc) vase Peer ase CRer ses Cay -crltase. a Cates cre Cee ser cra Reema es Ur cse ir Un Cuiae ee Meat Te CHeeeD ng Pre Reeee cet rea ches aes Eset sea Solution 1 en GLiae Meee Merces tse eee eRe Reem st ea Fy a} pee eee tose er ant a Me PMU icy cast ere One eewe tes cea + eae ee ote foaeeet cae ret ett ae Cree Me Mea yc Serene es Tce ewe cea ee eee ta eect vena pasta merged[i] - std::to_string(integers[integerIndex:+])5 i Solution 1 Dra a Se Meese ese L Td ‘int stringindex = 9; creates aay cee ae ea gee CHES ie ee a eye fre ee eee csr oa patra oye ROC Ee Mes AG hese ese urea CC aed gc Ren Gulag eee} std::cout << merged[i] << cout << std::endl; a eters ° Single Fe Programming Question op eonorptngctl to oeeiperertngin neces Sh commen aezamh ager We ce tenth cert ons ert he rimirnrerceretes nates exp ate corer renters em mip co ao ota oan Noes ort Manan eroeirer-aomn tees Pe ot Irevominacot he aur oes ‘ecrearinat coor pos op wane pga ht mee Wo gd Ory nel he mining ts ne ung ony rer he ian ne snore rane moaps atigesertoneetraeSay errant tito soreo queen cian gern manta tome ‘motrin contort ear mi Output format: The output prints the minimum element in the merged array. Sample test cases: Input 1: Output: 6 123452 7 a5e7866 Input 2: Output 2: 2 222 3456 Fill your code here Estate etregee petra aes tsa ced USUL Cert aay Pests ira SUMO et a Uren Ditac eet Temes Gy for (int i= 0; i< n5 Lees bar + teem Pea ete Ue ek cua eee ae eae ot ear uy ea iE vector mergedArray(arri.begin(), arri.end()); mergedarray.insert(mergedarray.end(), arr2.begin(), arr2.end()); tte Id na cin >> n3 vector arri(n)5 for (int i= 0; i > arra[i]; y cera Were ere for (int i = 0; i < m Urey ea + Was ee em ate CS ere SU) Pe LO mergedArray. insert (mergedArray.end(), arr2.begin(), arr2.end())5 int mintngredient = *min_element (mergedarray.begin(), mergedarray.end()); Co ameme bac Cin ame TH ewauad 0 Ynatconpiad Tenor 1! Hd tents Sage Memepeing Sie gone ote came nonsticins 0 sfe Tetcoros oseed ‘compteressoge rertcaee cu sous time) Tmecomplaty ——Spcecomplnty ——_weseage e esas = corp ris 2 e seca = corpitenricces ‘ine pe compan cet nape cnt ‘ e sccet = coroton sce ape nt cpt ouput contre se ep pa censretoups ao CUO SraPtseertce ete ae rico Caper Coon Poe int array2[size2]; eects Cosemorien Fe Cae a ee Coe eer recon Se cra Sone Pe oan (CUlae meet ae teary e(- Cn Eeo Ie | mergedarray[mergedSize] = arrayi[i]; Deere int i - 03 i < size2; i++) { freee) aad access ey] release amy minElement = mergedarray[0]5 (int i = 15 i < mergedsizes i++) { Cy ae Feet ac oe (rust ae es aera ay } } eevee ata olka’ fo

You might also like