: ________________________________________
________________________________________
________________________________________
__ , ____________________________
, ,
______________________________________________
, , ,
_____ ____________ . ____________________________
2015.
. 3
1 .. 4
2 . 4
3 . 5
4 . 7
5 -. 10
6 .. 26
. 28
.. 29
1. .. 30
C++ - , , . C++ C. , C, C++ . , , . . , . , . -. , . C++ . - , . , , , , , .
C++ , . , C. C++ C , C++ , C.
, , , - ++, , .
. . . . .
() , . , / , . , (Integrated development environment- IDE). , . , , , (), , . , - , , . , Eclipse Microsoft Visual Studio, .
IDE , .
, , . : , , ++Builder IDE, PLSQL Developer Oracle, Cristal Reports , StarTeam .
Microsoft Visual Studio 2013.
Microsoft Visual Studio Microsoft, . , , Windows Forms, -, -, - , , Windows, Windows Mobile, Windows CE,.NET Framework, Xbox, Windows Phone.NET Compact Framework Silverlight.
Visual Studio IntelliSense . , . , -, . Visual Studio () , (, , Subversion Visual SourceSafe), (, - (, Team Explorer Team Foundation Server).
-
Cities. , . set get .
. Enter.
, .
, , , . , , .
. , , . Visual Studio 2013. . - , , . , .
1. . - 21 . . - 2002. - 672.
2. . Microsoft Visual Studio 2010 = Microsoft Visual Studio 2010: A Beginner's Guide (A Beginners Guide). C.: -, 2010. . 464. ISBN 978-5-9775-0609-0.
3. . . C++ : . . 2. - : ; : , 1992, 304-345.
4. . - C++: . . - : , 1995. 480.
5. . . C++ : . . - : , 1997. 736.
1.
Cities.h
#include "stdafx.h"
#include <string> //
#include <iostream> // /
#include <fstream> // (/)
using namespace std;
class Cities
{
public:
Cities();
~Cities();
void setCity(string _city);
void setSelected(bool _selected);
string getCity();
bool getSelected();
private:
string city;
bool selected;
};
Cities.cpp
#include "stdafx.h"
#include "Cities.h"
Cities::Cities()
{
city = "";
selected = false;
}
Cities::~Cities()
{
}
void Cities::setCity(string _city)
{
city = _city;
}
void Cities::setSelected(bool _selected)
{
selected = _selected;
};
string Cities::getCity()
{
return city;
};
bool Cities::getSelected()
{
return selected;
};
CACities.cpp
// CACities.cpp: .
//
#include "stdafx.h"
#include <windows.h> // .
#include <locale.h> //
#include <string> //
#include "Cities.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
setlocale(LC_ALL, "rus"); //
system("chcp 1251");
const string fileName = "Cities.txt";
ifstream fin(fileName);
string s, inputStr, inputChar, findStr, str;
int countCities = 0, j = 0;
char c;
string nameCity, lastCharNameCity; //s - , nameCity -
int numCity = 0; //
bool findWord, noMatches = true, endGame = false; // ,
if (!fin)
{
cout << " " << endl;
}
else
{
//
while (!fin.eof())
{
getline(fin, s);
countCities++;
}
//
fin.clear();
fin.seekg(0, ios_base::beg);
Cities *cities = new Cities[countCities];
while (!fin.eof())
{
getline(fin, s); //
cities[j].setCity(s);
j++;
}
cout << " ! \n";
cout << " : \n";
cout << " , \n";
cout << " , \n";
cout << ". : \n";
cout << " ! \n";
cout << " : \n";
cin >> inputStr;
if (inputStr == "")
{
return 0;
}
do {
//
for (j = 0; j < countCities; j++)
{
s = cities[j].getCity();
nameCity = s.substr(0, s.find('(') - 1);
if (inputStr == nameCity &&!cities[numCity].getSelected())
{
findWord = true;
numCity = j;
noMatches = false;
break;
}
else
findWord = false;
}
//
if (!findWord)
{
cout << " , : \n";
cin >> inputStr;
if (inputStr == "")
{
cout << " \n";
system("pause");
return 0;
}
}
} while (noMatches);
//
cout << cities[numCity].getCity();
cities[numCity].setSelected(true);
//
s = nameCity;
lastCharNameCity = s[s.length() - 1];
if (lastCharNameCity == "")
lastCharNameCity = s[s.length() - 2];
do {
noMatches = true;
//
do {
for (j = 0; j < countCities; j++)
{
s = cities[j].getCity();
nameCity = s.substr(0, 1);
nameCity = tolower(nameCity[0]);
if (lastCharNameCity == nameCity &&!cities[j].getSelected())
{
findWord = true;
numCity = j;
noMatches = false;
break;
}
else
findWord = false;
}
if (!findWord)
{
cout << "! .\n";
system("pause");
return 0;
}
else
{
cout << "\n" << cities[numCity].getCity() << "\n";
cities[numCity].setSelected(true);
}
} while (noMatches);
cout << " : \n";
s = cities[numCity].getCity();
s = s.substr(0, s.find('(') - 1);
lastCharNameCity = s[s.length() - 1];
if (lastCharNameCity == "")
lastCharNameCity = s[s.length() - 2];
cout << " : " << lastCharNameCity << "\n";
cin >> inputStr;
if (inputStr == "")
{
cout << " \n";
system("pause");
return 0;
}
s = nameCity;
noMatches = true;
//
do {
for (j = 0; j < countCities; j++)
{
s = cities[j].getCity();
inputChar = s.substr(0, 1);
inputChar = tolower(s[0]);
s = s.substr(0, s.find('(') - 1);
if (lastCharNameCity == inputChar && inputStr == s &&!cities[j].getSelected())
{
findWord = true;
numCity = j;
noMatches = false;
break;
}
else
findWord = false;
}
if (!findWord)
{
cout << " , : \n";
cout << " : " << lastCharNameCity << "\n";
cin >> inputStr;
if (inputStr == "")
{
cout << " \n";
system("pause");
return 0;
}
}
else
{
cout << cities[numCity].getCity();
cities[numCity].setSelected(true);
s = cities[numCity].getCity();
s = s.substr(0, s.find('(') - 1);
lastCharNameCity = s[s.length() - 1];
if (lastCharNameCity == "")
lastCharNameCity = s[s.length() - 2];
}
} while (noMatches);
} while (!endGame);
}
system("pause");
return 0;
}
: 2016-12-18 ; ! ; : 1119 |
:
:
, ==> ...
1918 - | 1833 -
© 2015-2024 lektsii.org - -
: 0.1 .