escreva um algoritmo que leia três notas, calcule e imprima a média aritmética
Continuando com a série de posts, onde vou postar alguns algoritimos resolvidos em linguagem C e também em python.
escreva um algoritmo que leia três notas, calcule e imprima a média aritmética.
Em C:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>int main(int argc,char**argv[]){float nota1,nota2,nota3;printf("digite a primeira nota: ");
scanf("%f",¬a1);printf("digite a segunda nota: ");
scanf("%f",¬a2);printf("digite a terceira nota: ");
scanf("%f",¬a3);printf("a media aritmetica e: %f",(nota1+nota2+nota3)/3);return0;}
Em Python:
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env pythondef main():
nota1 = input("digite a primeira nota: ")
nota2 = input("digite a segunda nota: ")
nota3 = input("digite a terceira nota: ")print"a media aritmetica e: ", (nota1+nota2+nota3)/3
if __name__ == "__main__":
main()
qualquer dúvida ou se você quiser propor um algoritmo é só deixar um comentário!
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);return0;}
Em Python:
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env pythondef 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!
>>> 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 sourcein/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 forgrep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep-E
checking forld 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 forld 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:
A Microsoft possui no portal Technet várias Academias para estudo teórico, dentre eles a academia de segurança que está fazendo bastante sucesso.
A academia de Gerenciamento fala sobre ITIL, excelente material para quem está estudando, pode testar os conhecimentos fazendo as provas.
O que são as Academias?
Um programa da Microsoft para fonte de estudo através de aprovação em prova realizada ao fim de cada módulo.
Pelo que percebi, algumas pessoas estão com dificuldades para fazer download de drivers aqui do blog, então preparei um rápido tutorial ensinando a fazer download via easy share.
1º passo: Aguarde a contagem terminar.
2º passo: Clique em free download.
3º passo: Digite o código e clique no botão Download the file
para visualizar esse tutorial em uma imagem, CLIQUE AQUI!
Quando você está trabalhando com banco de dados, nesse caso Php e MySQL é muito útil para o desenvolvedor obter informações nais detalhadas sobre o problema, de forma que o problema fique mais explícito, ficando mais fácil arrumá-lo.
Você pode utilizar o mysql_error() e o mysql_errno() para obter a mensagem de erro do mysql e colocá-la na tela para você.
mysql_error() -> Retorna o texto da mensagem de erro da operação MySQL anterior.
mysql_errno() -> Retorna o valor numérico da mensagem de erro da operação MySQL anterior.
Um exemplo de como utilizar o mysql_error():
1
mysql_connect("localhost","username","password") or die(mysql_error())
O exemplo abaixo retornará um erro se houver um problema de conexão com seu banco de dados MySQL:
1
$valor = mysql_query($query) or die("Ocorreu um erro no MySQL.<br />Query utilizada: " . $your_query . "<br /> Erro: (" . mysql_errno() . ") " . mysql_error())