,   CyberForum.ru

- C++

C++ k 3x3. k http://www.cyberforum.ru/cpp-beginners/thread1220866.html
k 3x3. k
C++ N. N. http://www.cyberforum.ru/cpp-beginners/thread1220864.html
C++ 2
N. 2 . ,
C++
- n .
C++ Cout http://www.cyberforum.ru/cpp-beginners/thread1220853.html
( ), . , .
C++ ++. . ( , ). : #include <iostream> #include <conio.h> using namespace std; int main() { setlocale (LC_CTYPE,"Russian");

saharok2000
1 / 1 / 0
: 01.07.2014
: 49
01.07.2014, 21:28  []    
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <cstring>
using namespace std;
 
ifstream* openFile()
{
    ifstream* pFileStream = 0;
    for(;;)
    {
        char fileName[50] = {'l', 'o', 'g', 'i', 'n', 's', '_', 'p' ,'a', 's', 's', 'w', 'o', 'r', 'd', 's', '.', 't', 'x', 't'};
        //îòêðûâ*åì ô*éë äëÿ ÷òå*èÿ
        //*å ñîçä*â*òü, åñëè *å ñóùåñòâóåò
        pFileStream = new ifstream(fileName);
        if (pFileStream->good())
        {
            break;
        }
        cerr << "Íåâîçìîæ*î îòêðûòü ô*éë " << fileName << endl;
        delete pFileStream;
    }
    return pFileStream;
}
 
int register_()
{
    char login[40];
    char password[40];
    char theLogPass[100];
    cout << "Ïðèäóì*éòå ëîãè* " << endl;
    cout << "->";
    cin >> login;
    cout << "Ïðèäóì*éòå ï*ðîëü " << endl;
    cout << "->"; 
    cin >> password;
    strcpy(theLogPass,login);
    strcat(theLogPass,password);
 
    // ç*ïèñü ä***ûõ
    ofstream fout("logins_passwords.txt", ios::app);
    fout << theLogPass;
    fout << endl;
    fout.close();
    cout << "Âû óñïåø*î ç*ðåãèñòðèðîâ**û!!!" << endl;
}
 
int loginer()
{
    char the_log[40];
    char the_pass[40];
    char the_log_pass[100];
    cout << "Ââåäèòå ñâîé ëîãè*" << endl;
    cout << "->";
    cin >> the_log;
    cout << "Ââåäèòå ï*ðîëü" << endl;
    cout << "->";
    cin >> the_pass;
    strcpy(the_log_pass,the_log);
    strcat(the_log_pass,the_pass);
    cout << the_log_pass << endl;
    
    //ïîëó÷å*èå ô*éëîâîãî ïîòîê*
    ifstream* pFileStream = openFile();
    
    //îñò**îâèòñÿ ïî äîñòèæå*èþ êî*ö* ô*éë*
    while (!pFileStream->eof())
    {
        //÷òå*èå ç**÷å*èÿ
        char value[100];
        (*pFileStream) >> value;
        
        // îñò**îâê* ïðè îøèáêå ÷òå*èÿ
        //(**ïðèìåð, ñ÷èòûâ*åòñÿ *å öåëîå ÷èñëî, èëè
        //ñ÷èò** ñèìâîë *îâîé ñòðîêè ïîñëå êîòîðîãî 
        //*è÷åãî *åò
        if (pFileStream->fail()){
            break;
        }
        //âûâîä ñ÷èò***îãî ç**÷å*èÿ
        if(value == the_log_pass){
            cout << "Äîñòóï ð*çðåøå*" << endl;
        }else{
            cout << "Îøèáê* *ó*òåôèê*öèè!!!" << endl;
        }
    }
    delete pFileStream;
}
 
 
 
int main ()
{
    setlocale(LC_ALL, "");
    string v_log = "login";
    string v_reg = "register";
    string otvet;
    
    cout << "Ïðèâåò ÷åëîâåê!!! \n×òîáû ïîï*ñòü â ìèð êîìïüþòåð* " 
    << "*åîáõîäèìî âîéòè èëè ç*ðåãèñòðèðîâ*òüñÿ." << endl;
    cout << "Ââåäèòå login ÷òîáû âîéòè èëè register äëÿ ðåãèñòð*öèè." << endl;
    cout << "->";
    cin >> otvet;
    
    if(otvet == v_log){
        loginer();
    }
    if(otvet == v_reg){
        register_();
    }
    system("pause");
    return 0;
}
 
: 22:30. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
@Mail.ru