,   CyberForum.ru

- C++


C++ http://www.cyberforum.ru/cpp-beginners/thread1779383.html
#include<iostream> using namespace std; int* BuildArray(int n){ int* arr=new int; int flag = 0; while (flag != 1){ flag = 1; cout << "Enter a array: ";
C++ dll , : dll , - dll . ? - , . dll : , , . ,... http://www.cyberforum.ru/cpp-beginners/thread1779369.html
C++
. , . #include <iostream> #include <deque> #include <algorithm> using namespace std; int main() { deque<int> d1;
C++ ++
, if ++? if ( ch == '' ) a_grade + + ;
C++ HID http://www.cyberforum.ru/cpp-beginners/thread1779276.html
! : HID . : HID . - Vendor ID 8352 (= 0x20A0 hex). - Product ID 16738 (= 0x4162 hex).
C++ while ? . , : while , h 50 250, . , , 49.9, ...

Anikin
4 / 4 / 4
: 20.06.2016
: 41
: 1

- C++

11.07.2016, 23:31. 165. 7
( )

. . : "List is not a class template". , List .
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#ifndef LIST_H
#define LIST_H
#include <iostream>
#include <assert.h>
 
using namespace std;
 
//êë*ññ óçåë ñïèñê*
template <class NODETYPE>
class ListNode {
    friend class List<NODETYPE>;    //îáúÿâëå*èå List äðóæåñòâå**ûì êë*ññîì
    
public:
    ListNode(const NODETYPE& );     //êî*ñòðóêòîð
    NODETYPE getData() const;       //âîçâð*ù*åò ä***ûå óçë*
private:
    NODETYPE data;                  //ä***ûå
    ListNode* nextPtr;              //ñëåäóþùèé óçåë â ñïèñêå
};
 
//êî*ñòðóêòîð
template<class NODETYPE>
ListNode<NODETYPE>::ListNode(const NODETYPE& info)
{
    data = info;
    nextPtr = 0;
}
 
//âîçð*ùå*èå ä***ûõ óçë*
template<class NODETYPE>
NODETYPE ListNode<NODETYPE>::getData() const { return data; }
 
//êë*ññ ñïèñîê
template <class NODETYPE>
class List {
public:
    List();         //êî*ñòðóêòîð
    ~List();        //äåñòðóêòîð
    void insertAtFront(const NODETYPE&);
    void insertAtBack(const NODETYPE&);
    int removeFromFront(NODETYPE&);
    int removeFromBack(NODETYPE&);
    int isEmpty() const;
    void print() const;
private:
    ListNode<NODETYPE>* firstPtr;                   //óê*ç*òåëü ** **÷*ëî ñïèñê*
    ListNode<NODETYPE>* lastPtr;                    //óê*ç*òåëü ** êî*åö
    ListNode<NODETYPE>* getNewNode(const NODETYPE&);    //óòèëèò*
};
 
//êî*ñòðóêòîð ñ óìîë÷**èåì
template <class NODETYPE> 
List<NODETYPE>::List() { firstPtr = lastPtr = 0;}
 
//äåñòðóêòîð
template <class NODETYPE>
List<NODETYPE>::~List()
{
    if(! isEmpty() ) 
    {       //ñïèñîê *å ïóñòîé
    cout << "Óä*ëå*èå óçëîâ...\n";
    
    ListNode<NODETYPE> *currentPtr = firstPtr, *tempPtr;
    
    while (currentPtr != 0) 
        {
        tempPtr = currentPtr;
        cout << tempPtr->data << endl;
        currentPtr = currentPtr->nextPtr;
        delete tempPtr;
        } 
    
    }
 
    cout << "Âñå óçëû óä*ëå*û" << endl << endl;
}
 
//äîá*âèòü óçåë â **÷*ëî
template <class NODETYPE>
void List<NODETYPE>::insertAtFront(const NODETYPE& value) 
{
    ListNode<NODETYPE> *newPtr = getNewNode(value);
    
    if (isEmpty())
    firstPtr = lastPtr = newPtr;
    else 
    {
    newPtr->nextPtr = firstPtr;
    firstPtr = lastPtr;
    }
 
}
    
//äîá*âèòü óçåë â êî*åö
template <class NODETYPE>
void List<NODETYPE>::insertAtBack(const NODETYPE& value) 
{
    ListNode<NODETYPE> *newPtr = getNewNode(value);
    
    if (isEmpty())
    firstPtr = lastPtr = newPtr;
    else 
    {
    lastPtr->nextPtr = newPtr;
    lastPtr = newPtr;
    }
}
//óä*ëèòü óçåë ñ **÷*ë*
template <class NODETYPE>
int List<NODETYPE>::removeFromFront(NODETYPE& value)
{
    if (isEmpty())      //*åóä*÷*îå óä*ëå*èå
    return 0;
    else {
    
        ListNode<NODETYPE>* tempPtr = firstPtr;
        if (firstPtr == lastPtr)
        firstPtr = lastPtr = 0;
        else 
        firstPtr = firstPtr->nextPtr;
        
    value = tempPtr->data;
    delete tempPtr;
    
    return 1;       //óñïåø*îå óä*ëå*èå
    }
}
 
//óä*ëèòü óçåë ñ êî*ö*
template <class NODETYPE>
int List<NODETYPE>::removeFromBack(NODETYPE& value)
{
    if (isEmpty())      //*åóä*÷*îå óä*ëå*èå
    return 0;
    else {
    
        ListNode<NODETYPE>* tempPtr = firstPtr;
        if (firstPtr == lastPtr)
        firstPtr = lastPtr = 0;
        else {
        ListNode<NODETYPE>* currentPtr = firstPtr;
        
        while(currentPtr->nextPtr != lastPtr)
        currentPtr = currentPtr->nextPtr;
        
        lastPtr = currentPtr;
        currentPtr->nextPtr = 0;
        }
    value = tempPtr->data;
    delete tempPtr;
    
    return 1;       //óñïåø*îå óä*ëå*èå
    }
 
}
 
//ïóñòîé ëè ñïèñîê 1 - ïóñòîé 0 - *åò
template <class NODETYPE>
int List<NODETYPE>::isEmpty() const { return firstPtr == 0; }
 
//âîçâð*ùå*èå óê*ç*òåëÿ ** áëèæ*éøèé óçåë
template <class NODETYPE> 
ListNode<NODETYPE>* List<NODETYPE>::getNewNode(const NODETYPE& value)
{
    ListNode<NODETYPE>* ptr = new ListNode<NODETYPE>(value);
 
    assert(ptr != 0);
    return ptr;
}
 
//print
template <class NODETYPE>
void List<NODETYPE>::print() const 
{
    if (isEmpty() ) {
    cout << "Ñïèñîê ïóñò\n\n";
    return;
    }
    
    ListNode<NODETYPE>* currentPtr = firstPtr;
    cout << "Ñïèñîê ñîñòîèò èç: ";
    
    while(currentPtr != 0) {
    cout << currentPtr->data << ' ';
    currentPtr = currentPtr->nextPtr;
    } 
    cout << endl << endl;
    
}
#endif
.
 
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru