You are on page 1of 7
611723, 7:34PM 5 bit dau vao Thi 31 Thing nim 2023, 1223 AM lie Tinh trang. 93 hoan thanh Hoan than vo Thi tu, 31 Thing nim 2023, 957 AM lie Thal gian thyve 9 gid 34 phi ign 2,00/2.00 Dim 10,00 cia 10,00 (100%) Funetion_PostLab: Attempt review wr 611723, 7:34PM Funetion_PostLab: Attempt review cau hoi 1 Ming view \Viét ham tm che xuathign nu fin nht trong mat chub va sé Bn xult hign ca chi c8i dé, Nu cd nhibu eh Bi c6 tty alphabet nhé hat, tha min, xde dinh char Diu vie: const char str: chugi ky ty dang x6t,chi bao gm chi ci thung vi hoa Bau ra: + chart res: chi ci xust ign nhidy fin nit trong chu st + int frag 3 Fin wut hin cis che ‘Cha tham 56 res [chi Si thuding. CRO él vit hoa strong str > strttls stefn] = 85 Ant frea rostFrequentCharacter(ste, res, fre); detete(} tes " in 99 95 oman chart ste = new char{nv: for(int 1 = 0; 4 Cnp S44) cin >> strtiys stefan] = nt freq = 6; rostFrequentCharacter(ste, res, fre); cout ce res ce” ee fre: deletel] sts ‘Answer: (penalty regime: 0%) Reset answer i [include ntps:ife-eaming nemut.edu.vnimodiquiireview:ohpattempt=11460298cm a 611723, 7:34PM Funetion_PostLab: Attempt review 2 [void mostFrequenscharacter(char* str, char res, int& freq) { strlen(str); 4 ear 5 6 | ces = "2s 7 | char *doc'= new char net; Be] for (int 1 = 9; 1 < nj ive)( 3 Ef(ste[i] < 2°) (aoer Fry else doc{i} = str[i); uf} a2 | Goctn} = 95 134] for (int Ls 0; Lc m5 denne 14 lap as4| for = 55 5 < ny GONE a sF(doc{i] == doc{]) lapres 1 y ys, if (ap > freq) ¢ 2 freq = Lap; 2 res = doclt]; 2 y 23 else if ( lap == freq 88 doc[i) < res) res = doc{ il; va} y as | ntps:ifeJeaming hemut.edu vrimod/quiiroviow php attempt=11480288cmid=100722 a7 611723, 7:34PM Funetion_PostLab: Attempt review Test Input | Expected Got vo int 7 32 aw chact str = now charts for(int 4 = 05 4 > stelle stefa} = char nes = 8 sot freq rnostrrequentCharacter(str, res, fea); cout ce res ce ce Fras deletet] sts vant a5 s jor iw cin >> ni onmeas chaet str = new charts For(int 1 = 85 4 € nj S09) cin >> stelle stefa} = char res = 8 nt freq = rnostFrequentCharacter(str, res, fea); detetet] sts Passed all tests! ¥ im eno bi np may 100/300. an 611723, 7:34PM Funetion_PostLab: Attempt review cau hoi 2 Ming view Cho ha s5 ty nhign 9 va m, Hay vigt mat him tinh toan va tr v8 gid tr clan trong hé m phi, bi 465i tham 56 m dé e& gid tv mBcdinh Ia 2 wong nh nghia ham Diu vio: int 55 tynhiénn en due chuydn sang hé m phn inem:hg cos can chuyén i m ph cb 6 6 medi i 2 kh nh nga him Baur: int i team trong hm phn ‘Cha fu vb sé dm bbo gi Ute v8 Khang bi rn 56 (English) ‘Given two natural numbers n and m. Write a function that converts n to base m and returns that value, given that mis in 2, 4,8). Student must provide a default argument of value 2 forthe second parsmeter(n) Input: Jing: natural number n that needs to be converted gi tm thube 2 4 8) Sinh vién Bn thay. Int: the new base which nis converted to. The default argument ofthis parameter must be 2 when defining the function, Output: Int the value of min base m [Note: the input guarantees thatthe return value will nt cause integer overflow For exampl Test Input Result nt 9: 16208 cout <¢ convertTobasetn, 6) << "\e"s 0000 cout << convertTobaso¥(ny 8) € "\n"3 cout << convertropasen(n): nt 9: 2/230 cout << convertTobasoh(ny 4) €¢ "\nts 33100 cout << convertTobasoH(ny 8) € "\n"; cout << convertTonaseM(n): ‘Answer: (penalty regime: 0%) Reset answer T Hinclude 2+]ine convertToBaseM(int 9, int m = 2) ¢ 3) Snes a | imi 9 Saf white(s > 0)¢ 6 Xn + pow(ae,d) * (n Xm); > honda 8 ies s] 3 nh sr 611723, 7:34PM Funetion_PostLab: Attempt review cout << convertropased(n); Test Input Expected Got Yo int ns 18200 cout << convertropasem(n, 4) ¢¢ "a" 20008 cout << convertTopaseM(n, 8)

You might also like