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 maxn = 1000; struct stackk { int niza[maxn]; int idx; void init() { idx = -1; } void push(int x) { if(idx + 1 >= maxn) { cout << "NEMA DOVOLNO KAPACITET" << endl; return; } idx++; niza[idx] = x; } int pop() { if(idx == -1) { cout << "NEMA NITU EDEN ELEMENT VO STEKOT" << endl; return -1; } int result = niza[idx]; idx--; return result; } int top() { if(idx == -1) { cout << "NEMA NITU EDEN ELEMENT VO STEKOT" << endl; return -1; } return niza[idx]; } int size() { return idx + 1; } int isEmpty() { if(idx == -1) { return 1; } else { return 0; } } }; void promeni(stackk & m1) { stackk m2; m2.init(); while(m1.isEmpty() == false) { m2.push(m1.pop()); } stackk nad; nad.init(); while(m2.isEmpty() == false) { int c = m2.pop(); if(nad.isEmpty() == false) { if(c % nad.top() == 0) { m1.push(c / nad.top()); } } nad.push(c); if(m2.isEmpty() == false) { if(c % m2.top() == 0) { m1.push(c / m2.top()); } } } } int main() { stackk m1; m1.init(); m1.push(2); m1.push(10); m1.push(5); m1.push(2); m1.push(1); promeni(m1); while (!m1.isEmpty()) { cout << m1.pop() << endl; } return 0; }
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)