Procedure TForm1.Button4Click(Sender: TObject); var Buff: TNodePointer; x: TItem; i,j: Cardinal; begin i:=0; Buff:=Head; if(Buff^.Next=nil) then begin ShowMessage('В стеке один элемент!'); exit; end; while Buff <> nil do begin while (Buff^.Next<>nil) and (Buff^.Data=Buff^.Next^.Data) and not(isEmpty(Buff)) do begin pop(Buff^.Next,x); for j:=i to StringGrid1.RowCount-2 do StringGrid1.Cells[0,j]:=StringGrid1.Cells[0,j+1]; StringGrid1.RowCount:=StringGrid1.RowCount-1; end; Buff:=Buff^.Next; i:=i+1; end; end;
PS. Delphi у меня сейчас нет, так что проверяйте сами. Если что не так - сообщайте.
#include <iostream>
int main() {
setlocale(LC_ALL, "Russian");
int number;
std::cout << "Введите число: ";
std::cin >> number;
if (number >= 10) {
int last_digit, digit, s = 0;
last_digit = number % 10;
while (number != 0) {
digit = number % 10;
if (digit % 2 != 0) {
s += digit;
}
number /= 10;
}
if (s != 0) {
std::cout << "Сумма нечётных цифр: " << s << std::endl;
}
else {
std::cout << "Нет чётных цифр" << std::endl;
}
std::cout << "Разность первой и последней цифр: " << digit - last_digit << std::endl;
}
else {
if (number % 2 != 0) {
std::cout << "Сумма нечётных цифр: " << number << std::endl;
}
else {
std::cout << "Нет нечётных цифр" << std::endl;
}
}
return 0;
}