TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI KIBER XAVFSIZLIK FAKULTETI 713-21-GURUH TALABASI TEMIROVAMIRXONNING MA’LUMOTLAR TUZILMASI VA ALGARITMLAR FANIDAN 1-TOPSHIRIQI
2022
15.Berilgan matnli fayldan simvollarni o‘qib, ekranga chiqaring va raqamlarni ajratib ko‘rsating.
#include
#include
#include
#include
using namespace std;
int main()
{
ifstream inputFile;
string fileName;
char c;
int nNum = 0;
cout << "Enter the file name: ";
getline(cin, fileName);
// Open the file
inputFile.open(fileName.c_str());
// Check for successful opening
if(inputFile.fail())
{
cerr << "Error Opening File" << endl;
return(1);
}
while(!inputFile.eof())
{
inputFile.get(c);
if (c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u')
nNum++;
}
inputFile.close();
cout << nNum;
return 0;
}
Do'stlaringiz bilan baham: |