Toshkent Axborot Texnologiyalari Universiteti 712-19 guruh talabasi No’monov Murodjon
Download 13.18 Kb.
|
1-2-labaratoriya
- Bu sahifa navigatsiya:
- 2-labaratoriya ishi
Toshkent Axborot Texnologiyalari Universiteti 712-19 guruh talabasi No’monov Murodjon 1-labaratoriya 15. Берилган матнли файлдан символларни ўқиб, экранг чиқаринг ва рақамларни ажратиб кўрсатинг. #include #include #include using namespace std; int main () { string line; ifstream myfile ("example.txt"); if (myfile.is_open()) { while ( getline (myfile,line) ) { //use line here } myfile.close(); } else cout << "Unable to open file"; return 0; }
15. Stekni juft oʻrinda turgan elementlari oʻchirilsin. include #include #include using namespace std; // the contents of a stack static void printStack(stack { while (!s.empty()) { cout << s.top() << " "; s.pop(); } } // Function to delete all even // elements from the stack static void deleteEven(stack { stack // While stack is not empty while (!s.empty()) { int val = s.top(); s.pop(); // If value is odd then push if (val % 2 == 1) temp.push(val); } // Tranfer the contents of the temporary stack // to the original stack in order to get // the original order of the elements while (!temp.empty()) { s.push(temp.top()); temp.pop(); } // Print the modified stack content printStack(s); } // Driver Code int main() { stack s.push(16); s.push(15); s.push(29); s.push(24); s.push(19); deleteEven(s); return 0; } Download 13.18 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling