|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
07.04.2011, 07:53 | #1 |
Регистрация: 06.04.2011
Сообщений: 9
|
Опишите что делает программа на каждом шаге(
#include<iostream.h>
#include<stdlib.h> #include <conio.h> struct cell { char sign[10]; int weight; struct cell *next; }; void main () { clrscr(); struct cell *tmp; struct cell *head = NULL; struct cell *ends = NULL; cout << "Vvedite chisla konec 0:\n"; do { tmp = new struct cell; cin >> tmp -> sign; cin >> tmp -> weight; if (tmp -> weight == 0) { delete tmp; break; }; if (head == NULL && ends == NULL) head = tmp; else ends -> next = tmp; ends = tmp; ends -> next = NULL; } while (1); cout << "Spisok:\n"; tmp = head; while (tmp != NULL) { cout << tmp -> sign << " "<<tmp -> weight<<" "; tmp = tmp -> next; } int n; cout <<endl<< "vvedite chislo"; cin>> n; tmp = head; while (tmp != NULL) { if (tmp -> weight == n) { cout<< "takoy element estb v spiske!"; break; } else { tmp = tmp -> next; if (tmp == NULL) cout<<"takogo elementa v spiske nety!"; } } tmp = head; while (tmp != NULL) { if (tmp == ends) ends = tmp -> next; head = tmp -> next; delete tmp; tmp = head; } getch (); } мне нужно просто описание кождого шага( и во второй тоже самое плиз( #include<iostream.h> #include<stdlib.h> #include <conio.h> struct cell { int weight; struct cell *next; }; void main () { clrscr(); struct cell *tmp; struct cell *head = NULL; struct cell *ends = NULL; int a,b; cout << "Vvedite chisla konec 0:\n"; do { tmp = new struct cell; cin >> tmp -> weight; if (tmp -> weight == 0) { delete tmp; break; }; if (head == NULL && ends == NULL) head = tmp; else ends -> next = tmp; ends = tmp; ends -> next = NULL; } while (1); cout << "Spisok:\n"; tmp = head; while (tmp != NULL) { cout <<tmp -> weight<<" "; tmp = tmp -> next; } cout <<endl<< "obrabotanii spisok:"<<endl; tmp = head; while (tmp != NULL) { a = tmp -> weight; tmp = tmp -> next; b = tmp -> weight; if (a != b) cout<< a <<" "; } tmp = head; while (tmp != NULL) { if (tmp == ends) ends = tmp -> next; head = tmp -> next; delete tmp; tmp = head; } getch (); } |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Обьясните, что делает это программа??? | ~Леди~ | Общие вопросы Delphi | 2 | 05.04.2011 10:47 |
Что делает программа (забыл) С\С++ | Айдар | Помощь студентам | 6 | 27.06.2010 12:39 |
Как работает программа и что делает | dragun4ik | Помощь студентам | 0 | 23.05.2010 15:51 |
Печать. Что делает MS и не делает Delphi | Влад12 | Общие вопросы Delphi | 8 | 05.05.2010 20:04 |
что делает эта программа и где ошибка? | дангер | Паскаль, Turbo Pascal, PascalABC.NET | 27 | 28.01.2008 13:38 |