Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; const int max_size = 1000; struct stek { int niza[max_size]; int idx; void init() { idx = -1; } bool isEmpty() { if(idx == -1) { return true; } else { return false; } } bool isFull() { if(idx == max_size - 1) { return true; } else { return false; } } void push(int x) { if(isFull() == true) { cout << "nema poveke prostor vo stekot" << endl; exit(-1); } idx++; niza[idx] = x; } int peek() { if(isEmpty() == true) { cout << "nema element vo stekot" << endl; exit(-1); } return niza[idx]; } int pop() { if(isEmpty() == true) { cout << "nema element vo stekot" << endl; exit(-1); } int result = niza[idx]; idx--; return result; } int size() { return idx + 1; } }; void func(stek &m) { stek s1, s2; s1.init(); s2.init(); int sz = m.size() / 2; while(m.isEmpty() == false) { if(m.size() > sz) { s1.push(m.pop()); } else { s2.push(m.pop()); } } while(s1.isEmpty() == false) { m.push(s1.pop()); } int broj = 0; while(m.isEmpty() == false) { int c1 = m.pop(); int c2 = s2.pop(); int zbir = c1 + c2; if(zbir > 9) { zbir = 9; } broj = (broj * 10) + zbir; s1.push(zbir); } while(s1.isEmpty() == false ){ broj = (broj * 10) + s1.pop(); } cout << broj << endl; } int main() { stek s; int no, element, c; s.init(); cout << "Vnesete koj broj da se proveri:"; cin >> no; while(no != 0){ element = no % 10; no /= 10; s.push(element); } func(s); }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)