30
Filled under: c, programação, python | Thursday, April 30th, 2009 |
Archive for April, 2009
Esse é o primeiro post de uma série, onde vou postar alguns algoritimos resolvidos em linguagem C e também em python.
escreva um algoritmo que leia dois números inteiros e imprima a soma e o produto.
Em C:
1
2
3
4
5
6
7
8
9
10
11
12
13
| #include <stdio.h>
int main(int argc, char **argv[]){
int numero1,numero2;
printf("Digite o primeiro numero: ");
scanf("%d", &numero1);
printf("Digite o segundo numero: ");
scanf("%d", &numero2);
printf("O resultado da soma e: %d\n",numero1+numero2);
printf("O resultado do produto e: %d\n",numero1*numero2);
return 0;
} |
Em Python:
1
2
3
4
5
6
7
8
9
10
| #!/usr/bin/env python
def main():
numero1 = input("Digite o primeiro numero: ")
numero2 = input("Digite o segundo numero: ")
print "O resultado da soma e:" , numero1+numero2
print "O resultado do produto e:" , numero1*numero2
if __name__ == "__main__":
main() |
qualquer dúvida ou se você quiser propor um algoritmo é só deixar um comentário!
abraço,
até…
Tags:
algoritmo,
C
27
Filled under: dicas, gentoo, linux | Monday, April 27th, 2009 |
Archive for April, 2009
Após um longo tempo parado, voltaremos a atualizar o blog com mais frequência, o problema abaixo na instalação do pacote x11-libs/libxcb-1.1.90.1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
| >>> Emerging (20 of 62) x11-libs/libxcb-1.1.90.1
* libxcb-1.1.90.1.tar.bz2 RMD160 SHA1 SHA256 size ;-) ... [ ok ]
* checking ebuild checksums ;-) ... [ ok ]
* checking auxfile checksums ;-) ... [ ok ]
* checking miscfile checksums ;-) ... [ ok ]
>>> Unpacking source...
>>> Unpacking libxcb-1.1.90.1.tar.bz2 to /var/tmp/portage/x11-libs/libxcb-1.1.90.1/work
* Running elibtoolize in: libxcb-1.1.90.1
* Applying portage-1.5.10.patch ...
* Applying sed-1.5.6.patch ...
>>> Source unpacked in /var/tmp/portage/x11-libs/libxcb-1.1.90.1/work
>>> Compiling source in /var/tmp/portage/x11-libs/libxcb-1.1.90.1/work/libxcb-1.1.90.1 ...
* econf: updating libxcb-1.1.90.1/config.sub with /usr/share/gnuconfig/config.sub
* econf: updating libxcb-1.1.90.1/config.guess with /usr/share/gnuconfig/config.guess
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --prefix=/usr --datadir=/usr/share --disable-build-docs --disable-xselinux --enable-xinput
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for a Python interpreter with version >= 2.5... python
checking for python... /usr/bin/python
checking for python version... 2.6
checking for python platform... linux2
checking for python script directory... ${prefix}/lib64/python2.6/site-packages
checking for python extension module directory... ${exec_prefix}/lib64/python2.6/site-packages
checking for x86_64-pc-linux-gnu-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for CHECK... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for style of include used by make... GNU
checking for x86_64-pc-linux-gnu-gcc... x86_64-pc-linux-gnu-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether x86_64-pc-linux-gnu-gcc accepts -g... yes
checking for x86_64-pc-linux-gnu-gcc option to accept ISO C89... none needed
checking dependency style of x86_64-pc-linux-gnu-gcc... gcc3
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by x86_64-pc-linux-gnu-gcc... /usr/x86_64-pc-linux-gnu/bin/ld
checking if the linker (/usr/x86_64-pc-linux-gnu/bin/ld) is GNU ld... yes
checking for /usr/x86_64-pc-linux-gnu/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking how to run the C preprocessor... x86_64-pc-linux-gnu-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for x86_64-pc-linux-gnu-g++... x86_64-pc-linux-gnu-g++
checking whether we are using the GNU C++ compiler... yes
checking whether x86_64-pc-linux-gnu-g++ accepts -g... yes
checking dependency style of x86_64-pc-linux-gnu-g++... gcc3
checking how to run the C++ preprocessor... x86_64-pc-linux-gnu-g++ -E
checking for x86_64-pc-linux-gnu-g77... no
checking for x86_64-pc-linux-gnu-xlf... no
checking for x86_64-pc-linux-gnu-f77... no
checking for x86_64-pc-linux-gnu-frt... no
checking for x86_64-pc-linux-gnu-pgf77... no
checking for x86_64-pc-linux-gnu-cf77... no
checking for x86_64-pc-linux-gnu-fort77... no
checking for x86_64-pc-linux-gnu-fl32... no
checking for x86_64-pc-linux-gnu-af77... no
checking for x86_64-pc-linux-gnu-xlf90... no
checking for x86_64-pc-linux-gnu-f90... no
checking for x86_64-pc-linux-gnu-pgf90... no
checking for x86_64-pc-linux-gnu-pghpf... no
checking for x86_64-pc-linux-gnu-epcf90... no
checking for x86_64-pc-linux-gnu-gfortran... no
checking for x86_64-pc-linux-gnu-g95... no
checking for x86_64-pc-linux-gnu-xlf95... no
checking for x86_64-pc-linux-gnu-f95... no
checking for x86_64-pc-linux-gnu-fort... no
checking for x86_64-pc-linux-gnu-ifort... no
checking for x86_64-pc-linux-gnu-ifc... no
checking for x86_64-pc-linux-gnu-efc... no
checking for x86_64-pc-linux-gnu-pgf95... no
checking for x86_64-pc-linux-gnu-lf95... no
checking for x86_64-pc-linux-gnu-ftn... no
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... no
checking for g95... no
checking for xlf95... no
checking for f95... no
checking for fort... no
checking for ifort... no
checking for ifc... no
checking for efc... no
checking for pgf95... no
checking for lf95... no
checking for ftn... no
checking whether we are using the GNU Fortran 77 compiler... no
checking whether accepts -g... no
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from x86_64-pc-linux-gnu-gcc object... ok
checking for objdir... .libs
checking for x86_64-pc-linux-gnu-ar... x86_64-pc-linux-gnu-ar
checking for x86_64-pc-linux-gnu-ranlib... x86_64-pc-linux-gnu-ranlib
checking for x86_64-pc-linux-gnu-strip... x86_64-pc-linux-gnu-strip
checking if x86_64-pc-linux-gnu-gcc supports -fno-rtti -fno-exceptions... no
checking for x86_64-pc-linux-gnu-gcc option to produce PIC... -fPIC
checking if x86_64-pc-linux-gnu-gcc PIC flag -fPIC works... yes
checking if x86_64-pc-linux-gnu-gcc static flag -static works... yes
checking if x86_64-pc-linux-gnu-gcc supports -c -o file.o... yes
checking whether the x86_64-pc-linux-gnu-gcc linker (/usr/x86_64-pc-linux-gnu/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by x86_64-pc-linux-gnu-g++... /usr/x86_64-pc-linux-gnu/bin/ld -m elf_x86_64
checking if the linker (/usr/x86_64-pc-linux-gnu/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the x86_64-pc-linux-gnu-g++ linker (/usr/x86_64-pc-linux-gnu/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for x86_64-pc-linux-gnu-g++ option to produce PIC... -fPIC
checking if x86_64-pc-linux-gnu-g++ PIC flag -fPIC works... yes
checking if x86_64-pc-linux-gnu-g++ static flag -static works... yes
checking if x86_64-pc-linux-gnu-g++ supports -c -o file.o... yes
checking whether the x86_64-pc-linux-gnu-g++ linker (/usr/x86_64-pc-linux-gnu/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
checking for x86_64-pc-linux-gnu-gcc... (cached) x86_64-pc-linux-gnu-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether x86_64-pc-linux-gnu-gcc accepts -g... (cached) yes
checking for x86_64-pc-linux-gnu-gcc option to accept ISO C89... (cached) none needed
checking dependency style of x86_64-pc-linux-gnu-gcc... (cached) gcc3
checking for xsltproc... /usr/bin/xsltproc
checking for XCBPROTO... yes
checking for NEEDED... yes
checking for XDMCP... yes
checking for XdmcpWrap in -lXdmcp... yes
checking execinfo.h usability... yes
checking execinfo.h presence... yes
checking for execinfo.h... yes
checking XCBPROTO_XCBINCLUDEDIR... /usr/share/xcb
checking XCBPROTO_XCBPYTHONDIR... /usr/lib64/python2.6/site-packages
checking for ANSI C header files... (cached) yes
checking for library containing getaddrinfo... none required
checking for library containing connect... none required
checking for struct sockaddr_un.sun_len... no
checking whether x86_64-pc-linux-gnu-gcc supports symbol visibility... yes
checking whether documentation is built... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating doc/Makefile
config.status: creating xcb.pc
config.status: creating xcb-xlib.pc
config.status: creating xcb-composite.pc
config.status: creating xcb-damage.pc
config.status: creating xcb-dpms.pc
config.status: creating xcb-glx.pc
config.status: creating xcb-randr.pc
config.status: creating xcb-record.pc
config.status: creating xcb-render.pc
config.status: creating xcb-res.pc
config.status: creating xcb-screensaver.pc
config.status: creating xcb-shape.pc
config.status: creating xcb-shm.pc
config.status: creating xcb-sync.pc
config.status: creating xcb-xevie.pc
config.status: creating xcb-xf86dri.pc
config.status: creating xcb-xfixes.pc
config.status: creating xcb-xinerama.pc
config.status: creating xcb-xinput.pc
config.status: creating xcb-xprint.pc
config.status: creating xcb-xselinux.pc
config.status: creating xcb-xtest.pc
config.status: creating xcb-xv.pc
config.status: creating xcb-xvmc.pc
config.status: creating doc/xcb.doxygen
config.status: creating src/config.h
config.status: executing depfiles commands
Package: libxcb 1.1.90.1
Configuration
XDM support.........: yes
Build unit tests....: yes
Used CFLAGS:
CPPFLAGS............:
CFLAGS..............: -march=athlon64 -O2 -fomit-frame-pointer -pipe
Warning CFLAGS......: -Wall -pedantic -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wnested-externs
Installation:
Prefix..............: /usr
make
Making all in src
make[1]: Entering directory `/var/tmp/portage/x11-libs/libxcb-1.1.90.1/work/libxcb-1.1.90.1/src'
ln -s -f /usr/share/xcb/xproto.xml xproto.xml
/usr/bin/python ./c_client.py -p /usr/lib64/python2.6/site-packages /usr/share/xcb/xproto.xml
Traceback (most recent call last):
File "./c_client.py", line 2, in <module>
from xml.etree.cElementTree import *
File "/usr/lib64/python2.6/xml/etree/cElementTree.py", line 3, in <module>
from _elementtree import *
ImportError: No module named _elementtree
make[1]: *** [xproto.c] Error 1
make[1]: Leaving directory `/var/tmp/portage/x11-libs/libxcb-1.1.90.1/work/libxcb-1.1.90.1/src'
make: *** [all-recursive] Error 1
*
* ERROR: x11-libs/libxcb-1.1.90.1 failed.
* Call stack:
* ebuild.sh, line 48: Called src_compile
* environment, line 3095: Called x-modular_src_compile
* environment, line 3875: Called x-modular_src_make
* environment, line 3914: Called die
* The specific snippet of code:
* emake || die "emake failed"
* The die message:
* emake failed
*
* If you need support, post the topmost build error, and the call stack if relevant.
* A complete build log is located at '/var/tmp/portage/x11-libs/libxcb-1.1.90.1/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/x11-libs/libxcb-1.1.90.1/temp/environment'.
*
>>> Failed to emerge x11-libs/libxcb-1.1.90.1, Log file:
>>> '/var/tmp/portage/x11-libs/libxcb-1.1.90.1/temp/build.log' |
para resolver é só você recompilar o python com suporte a xml:
1
| USE="xml" emerge dev-lang/python |
abraço,
até…
Tags:
portage,
python,
xml