Tajriba mashg’ulotlari Mavzu. Fayllarni o’qish va yozish funksiyalari bilan ishlash
*/ 12 void process_name(ifstream& in_file, double& total)
Download 17.87 Kb.
|
13-14-laborIOM
- Bu sahifa navigatsiya:
- 20 if (total > 0) { cout 21 total = total - percent; 22 } 23 24 int main() 25 {
- 41 process_name(in_file, boy_total); 42 process_name(in_file, girl_total); 43 44 cout 45 } 46 47 return 0;
- Matnli fayllarga oid masalalar topshiriqlar
11 */
12 void process_name(ifstream& in_file, double& total) 13 { 14 string name; 15 int count; 16 double percent; 17 in_file >> name >> count >> percent; 18 19 if (in_file.fail()) { return; } // Har bir kiritishdan keyin muvaffaqiyatsizlikni Tekshiring 20 if (total > 0) { cout << name << " "; } 21 total = total - percent; 22 } 23 24 int main() 25 { 26 ifstream in_file; 27 in_file.open("babynames.txt"); 28 if (in_file.fail()) { return 0; } // Ochgandan so'ng muvaffaqiyatsizlikni tekshirish 29 30 double boy_total = 50; 31 double girl_total = 50; 32 33 while (boy_total > 0 || girl_total > 0) 34 { 35 int rank; 36 in_file >> ran 37 if (in_file.fail()) { return 0; } 38 39 cout << rank << " "; 40 41 process_name(in_file, boy_total); 42 process_name(in_file, girl_total); 43 44 cout << endl; 45 } 46 47 return 0; 48 } Natija 1 Michael Jessica 2 Christopher Ashley 3 Matthew Emily 4 Joshua Sarah 5 Jacob Samantha 6 Nicholas Amanda 7 Andrew Brittany 8 Daniel Elizabeth 9 Tyler Taylor 10 Joseph Megan ... 68 Dustin Gabrielle 69 Noah Katie 70 Caitlin 71 Lindsey ... 150 Hayley 151 Rebekah 152 Jocelyn 153 Cassidy Matnli fayllarga oid masalalar topshiriqlar
Download 17.87 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling