pastebin
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
pastebin
Follow @pastebin
create new paste
trending pastes
sign up
login
my settings
my profile
My Pastes
Public Pastes
Untitled
2 sec ago
python generator functi...
4 sec ago
BoneCraft SKIDROW rarbg...
4 sec ago
Untitled
9 sec ago
Untitled
10 sec ago
Untitled
20 sec ago
Untitled
15 sec ago
Untitled
15 sec ago
Layout Width
Share Pastebin
Jesuino
By: a guest | Jun 22nd, 2009 | Syntax:
C
| Size: 0.79 KB | Hits: 287 | Expires: Never
Download
|
Raw
|
Embed
|
Report abuse
This paste has a previous version,
view the difference
.
#include <stdio.h>
#include "pilha.c"
main
(
)
{
//Essa pilha tem o modelo no arquivo pilhas.c
pilha restos
;
//Função que simplesmente inicia nossa pilha
novaPilha
(
&
restos
,
100
)
;
//Número que iremos converter para binário
int
num
=
16
;
//Iremos empilhando os restos da divisão para realizar nossa conversão
do
{
//Empilhando
push
(
&
restos
,
num
%
2
)
;
// % = operador de resto
num
/=
2
;
}
while
(
num
>
1
)
;
//Empilha o último número
push
(
&
restos
,
num
)
;
//Vamos desempilhanto, salvando e imprimindo
while
(
(
num
=
pop
(
&
restos
)
)
!=
-
1
)
{
printf
(
"%d "
,
num
)
;
}
printf
(
"
\n
"
)
;
system
(
"pause"
)
;
}
create new paste
|
create new version of this paste
RAW Paste Data