Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
homework
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
// Example program #include <iostream> using namespace std; struct Dr{ int up; int down; }; Dr sokr(Dr dr){ int up = dr.up, down = dr.down; if((up % down) == 0){ up = up / down; down = 1; } else { int x = up, y = down; bool b = true; while(x!=y && b){ if(x>y){ x = x-y; } else { y = y-x; } if(x<=0 || y<=0){ b = false; } } if(b){ up = up / x; down = down / y; } } dr.up = up; dr.down = down; return dr; } int main(){ Dr dr; int x,y; cin >> x >> y; dr.up = x; dr.down = y; dr = sokr(dr); cout<< dr.up << '/' << dr.down; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion