Ejer jercic cicios ios resue esuelltos tos C++ C++ [pro [progr gram amac aciion est estruc ructur turada] ada]
http http:://f //foro. oro.el elha hack ckeer.net net/eje /ejerc rciicio cios/ej s/ejeerci rcicios cios_r _res esue uelltos tos_c_p _c_prrogra ograma maci cion on_e _e....
Bienvenido(a), Visitante . Por favor Ingresar o Registrarse ¿Perdiste tu email de activación?. 20 Junio Junio 201 2, 03:31
Tema destacado: Personaliza-Escoge el diseño del foro que más te guste. Foro de elhacker.net Programación Programación General Ejercicios Ejercicios resueltos C++ [programacion estructurada]
0
0 Usuarios y 11 Visitantes están viendo este tema.
Páginas: [1] 2
Autor Darvein
Desconectado Mensajes: 182
Tema: Ejercicios resueltos C++ [programacion [programacio n estructurada] (Leído 478,136 veces) Ejercicios resueltos C++ [programacion estructurada] « en: 26 Febrero 2008, 18:40 »
>> ARITMETICA << Mostrar los multiplos de 3 comprendidos entre los numeros 1 y 20
Código: =)
#i ncl ude #i ncl ude ude #i ncl ude ude i nt mai n ( ) { c l r s cr cr ( ) ; f or ( i nt i =1; i <=20; i ++) { cout <
Hallar A+B-C+100
Código: #i ncl ude #i ncl ude i nt mai n ( ) { i nt A, B, C; pr i nt f ( "I nser ser t e va val or par a A: A: pr i nt f ( "I nser ser t e va val or par a B: B: pr i nt f ( "I nser ser t e va val or par a C: C: pr i nt f ( " \ n%d + %d - %d + 100 100
") ; scan scanf ( "%d", &A) ; ") ; scan scanf ( "%d", &B) ; ") ; scan scanf ( "%d", &C) ; = %d", A, B, C, ( A+B+C- 100) 100) ) ;
Ejer jercic cicios ios resue esuelltos tos C++ C++ [pro [progr gram amac aciion est estruc ructur turada] ada]
http http:://f //foro. oro.el elha hack ckeer.net net/eje /ejerc rciicio cios/ej s/ejeerci rcicios cios_r _res esue uelltos tos_c_p _c_prrogra ograma maci cion on_e _e....
get ch( ch( ) ; }
Obtener (a-b)(a+b)
Código: #i ncl ude #i ncl ude ude i nt mai n ( ) { i nt a, b; pr i nt f ( "I nser ser t e val or a: " ) ; scan scanf ( "%d", &a) ; pr i nt f ( "I nser ser t e val or b: " ) ; scan scanf ( "%d", &b) ; pr i nt f ( " ( %d- %d) ( %d+%d) = %d", a, b, a, b, ( ( a- b) *( a+b) ) ) ; get ch( ch( ) ; }
Leer un numero de 3 digitos y sumarlos
Código: #i ncl ude #i ncl ude ude i nt mai n ( ) { i nt num numer o, sum_ di g=0; pr i nt f ( "I nsert e un un nu numero de de 3 di gi t os: ") ; scanf scanf ( "%d", &numero) ; i f ( numer o>=100) 100) { i nt num num=num numer o; / / sal vamos en num num, l a var i abl abl e num numer o whi l e ( num numer o! =0) { sum_di g=sum_di g+( num numer o%10) ; / / par par a sacar el ul t i mo di di gi t o de de nu numer o=num numer o/ 10; / / el i mi na el ul t i mo di di gi t o de de num numer o } pri nt f ( " La sum suma de de l os di di gi t os de de %d es : %d", num num, sum_di g) ; } el s e pr i nt f ( "\ a ERROR: El di gi t o no no ti ene 3 di gi t os") ; get ch( ch( ) ; }
Dado un numero verificar: - Que tenga dos digitos - Verificar si sus digitos son pares - Promediar sus digitos
Código: #i ncl ude #i ncl ude ude i nt mai n ( ) { i nt num numer o; pr i nt f ( "I nser ser t e num. de dos di di gi t os pa par es: ") ; sc anf anf ( " %d", &num numer o) ; i nt aux=numer o; i f ( numer o<100 && numer o>9) { i nt d1=numer o%10; numer o=numer o/ 10; i nt d2=numer o%10; i f ( d1% d1%2==0 & d2% d2%2==0) pr i nt f ( "El pr omedi o d l os di di gi t os de de %d es: es: %d", aux, ( d1+d2) / 2) ; } el s e pr i nt f ( "\ aER aERROR: el numero no no ti ene ene dos dos di di gi t os") ; get ch( ch( ) ; }
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
Dado un numero verificar si es positivo, negativo o nulo
Código: #i ncl ude #i ncl ude i nt mai n ( ) { i nt numer o; pr i nt f ( "I nser t e un numer o: ") ; sc anf ( " %d", &numer o) ; i f ( numer o==0) pr i nt f ( " El numer o %d es NULO" , numer o) ; el s e { i f ( numer o<0) pr i nt f ( " El numer o %d es NEGATI VO" , numer o) ; el s e pr i nt f ( " El numer o %d es POSI TI VO" , numer o) ; } get ch( ) ; }
Dados seis numeros enteros determinar, el menor de ellos
Código: #i ncl ude #i ncl ude i nt mai n( ) { i nt a, b, c, d, e, f ; pr i nt f ( "I nser t e num. 1: ") ; scanf ( "%d", pr i nt f ( "I nser t e num. 2: ") ; scanf ( "%d", pr i nt f ( "I nsert e num. 3: ") ; scanf ( "%d", pr i nt f ( "I nser t e num. 4: ") ; scanf ( "%d", pr i nt f ( "I nser t e num. 5: ") ; scanf ( "%d", pr i nt f ( "I nsert e num. 6: ") ; scanf ( "%d", i nt menor=a; i f ( b
&a) ; &b) ; &c); &d) ; &e) ; &f ) ;
" , a, b, c, d, e, f ) ;
Aprende el Metodo Silva Descarga el Mas Poderoso Metodo de Meditacion. Sonido Alfa Gratis. www Curso de Programacion PHP Formación profesional a distancia con certificación universitaria www. Lic. en Salud Publica Universidad a Distancia, Estudios en Salud Publica. www.aiu.edu/Universidad Software online eTask-it Plataforma corporativa que ayuda a incrementar tus ganancias. www.etas
En línea [www.darvein.org] Darvein
Desconectado
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #1 en: 26 Febrero 2008, 18:41 »
Ejercicios resueltos C++ [programacion estructurada]
Mensajes: 182
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
>> SERIES << hallar la sumatoria de: 2! + 4! + 6! + 8! + ...
Código: =)
#i ncl ude #i ncl ude i nt f ac t o ( i nt x ) { i nt f =1; f or ( i nt i =1; i <=x; i ++) {f =f * i ; } return (f); } i nt mai n ( ) { i nt n, ser i e=2, suma=0; pr i nt f ( "I nser t e cant i dad de ter mi nos a gener ar : ") ; scanf ( "%d", &n) ; f or ( i nt i =1; i <=n; i ++) { pr i nt f ( "%d! + ", ser i e) ; suma=suma+( f act o( ser i e) ) ; ser i e=ser i e+2; } pr i nt f ( " = %d" , suma) ; get ch( ) ; }
Generar la serie: 1, 5, 3, 7, 5, 9, 7, ..., 23
Código: #i ncl ude #i ncl ude i nt mai n ( ) { i nt ser i e=1; bool sw=t r ue; do { pr i nt f ( " %d, " , s er i e) ; i f ( sw) seri e+=4; el se ser i e- =2; sw=! sw; } whi l e ( ser i e<=23) ; get ch( ) ; }
Generar 5,10,15,20,25,30,35....n
Código: #i ncl ude #i ncl ude i nt mai n ( ) { i nt n, c=1, seri e=5; pr i nt f ( "Cant i dad de t er mi nos: ") ; scanf ( " %d" , &n) ; whi l e( c<=n) { pr i nt f ( " %d, " , s er i e) ; ser i e+=5; c++; } get ch( ) ; }
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
Si n=7 generar 7,6,5,4,3,2,1
Código: #i ncl ude #i ncl ude i nt mai n ( ) { i nt n, c=1; pr i nt f ( "Cant i dad de t er mi nos: ") ; scanf ( " %d" , &n) ; i nt ser i e=n; whi l e( c<=n) { pr i nt f ( " %d, " , s er i e) ; ser i e- - ; c++; } get ch( ) ; }
Windows Server Web, virtualización, seguridad, confiabilidad y productividad. www.iseweb.com Ayuda con los deberes Resolvemos 1000 tareas cada día! Rápido y gratis Misdeberes.es Computadoras Evuus Procesadores INTEL i3 e i5, HD ¡ El mejor precio en Venezuela ! www.evuus.c LD Premium Line Arrays, equipos PA Prueba la calidad al mejor precio.. www.ld-premium.com
En línea [www.darvein.org] Darvein
Desconectado Mensajes: 182
=)
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #2 en: 26 Febrero 2008, 18:42 »
>> VECTORES << /*Dado el vector T de tamao n. Si el tamao es par invertir los elementos de la mitad de los elementos Ejemplo: v=[1][2][3][4][5][6] v(invertido)=[3][2][1][6][5][4] */
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt V [ ] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " I ns er t e pos . [ %d] : " , i ) ; scanf ( "%d", &V[ i ] ) ; } } voi d most rar ( i nt V [ ] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " [ %d] " , V[ i ] ) ; } } voi d i nvi er t e ( i nt V [ ] , i nt d) { i nt aux1;
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
i nt f i n1 = d / 2; f or ( i nt i = 1 ; i <= ( d / 2) / 2 ; i ++) { aux1 = V [ i ] ; V [ i ] = V [ f i n1] ; V [ f i n1] = aux1; f i n1- - ; } f i n1 = d; f or ( i nt j = ( d / 2) + 1 ; j <= ( d / 2) + 1 ; j ++) { aux1 = V [ j ] ; V [ j ] = V [ f i n1] ; V [ f i n1] = aux1; f i n1- - ; } } i nt mai n ( ) { i nt V[ 20] ; i nt d; pr i nt f ( "I nser t e di men. del vector: ") ; scanf ( "%d", &d) ; l l enar ( V, d) ; pr i nt f ( "\ nVECTOR ORI GI NAL: \ n" ) ; mostr ar ( V, d) ; pr i nt f ( " \ n\ nVECTOR LUEGO DE LA I NVERSI ON: \ n") ; i nvi er t e ( V, d) ; mostr ar ( V, d) ; get ch( ) ; }
/*Dado un polinomio evualuarlo en el punto x (todo en un vector)*/
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " I ns er t e pos . [ %d] : " , i ) ; scanf ( "%d", &V[ i ] ) ; } } voi d most rar ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " [ %d] " , V[ i ] ) ; } } i nt pot enc i a ( i nt b, i nt e) { i nt p = 1; f or ( i nt i = 1 ; i <= e ; i ++) { p = p * b; } return (p); } voi d eval ua ( i nt V [ ] , i nt d, i nt x) {
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
i nt s = 0; f or ( i nt i = 1 ; i <= d ; i += 2) { s = s + ( V [ i ] * pot enci a ( x, V [ i + 1] ) ) ; } pr i nt f ( "\ n\ nX es i gual a: %d", s) ; } i nt mai n ( ) { i nt V[ 20] ; i nt d, x; pr i nt f ( "I nsert e di men. del vector: ") ; scanf ( " %d" , &d) ; pr i nt f ( " I ns er t e val or de ( x ) : " ) ; scanf ( " %d" , &x) ; l l enar ( V, d) ; pr i nt f ( "\ nVECTOR: ") ; mostr ar ( V, d) ; eval ua ( V, d, x); get ch( ) ; }
En línea [www.darvein.org] Darvein
Desconectado Mensajes: 182
=)
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #3 en: 26 Febrero 2008, 18:44 »
>> MATRICES << Generar la matriz: [01][02][03][04] [08][07][06][05] [09][10][11][12]
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt f , i nt c ) { i nt k=1; f or ( i nt i =1; i <=f ; i ++) { i f ( i %2! =0) { f or ( i nt j =1; j <=c; j ++) { M[ i ] [ j ] =k; k++; } } el s e { f or ( i nt j =c; j >=1; j - - ) { M[ i ] [ j ] =k; k++; } } } } voi d most rar ( i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i =1; i <=f ; i ++)
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
{ pr i nt f ( " \ n" ) ; f or ( i nt j =1; j <=c; j ++) { pr i nt f ( " [ %d] " , M[ i ] [ j ] ) ; } } } i nt mai n ( ) { i nt f , c; i nt M[ 20] [ 20] ; pr i nt f ( " I ns er t e f i l as de M: " ) ; s canf ( " %d" , &f ) ; pr i nt f ( "I nser t e col s. de M: ") ; scanf ( "%d", &c); l l enar ( M, f , c) ; most r ar ( M, f , c); get ch( ) ; }
Generar la matriz: [01][02][03][04] [05][06][07][00] [08][09][00][00] [10][00][00][00]
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt d) { i nt cont =1; f or ( i nt i =1; i <=d; i ++) { f or ( i nt j =1; j <=d; j ++) { i f ( ( i +j ) <=( d+1) ) {M[ i ] [ j ] =cont ; cont ++; } el s e M[ i ] [ j ] =0; } } } voi d most r ar ( i nt M[ 20] [ 20] , i nt d) { f or ( i nt i =1; i <=d; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j =1; j <=d; j ++) { pr i nt f ( " [ %d] " , M[ i ] [ j ] ) ; } } } i nt mai n ( ) { i nt d; i nt M[ 20] [ 20] ; pr i nt f ( "I nser t di men: ") ; scanf ( "%d", &d) ; l l enar ( M, d) ; most r ar( M, d) ; get ch( ) ; }
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
Dadas dos matrices A y B intercambiar los minimos de A con los maximos de B
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; scanf ( "%d", &M[ i ] [ j ] ) ; } } } voi d most rar ( i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M[ i ] [ j ] ) ; } } } i nt menor ( i nt M[ 20] [ 20] , i nt f , i nt c) { i nt men = M [ 1] [ 1] ; f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { i f ( M [ i ] [ j ] < men) men = M [ i ] [ j ] ; } } r et ur n ( men) ; } i nt maxi mo ( i nt M[ 20] [ 20] , i nt f , i nt c) { i nt max = M [ 1] [ 1] ; f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { i f ( M [ i ] [ j ] > max) max = M [ i ] [ j ] ; } } r et ur n ( max) ; } voi d i nt er c ambi ar ( i nt A[ 20] [ 20] , i nt f a, i nt c a, i nt B[ 20] [ 20] , i nt f b, { i nt mi n_a = menor ( A, f a, ca) ; i nt max_b = maxi mo ( B, f b, cb) ; / / par a cambi ar l os mi ni mos de A con l os maxi mos de B f or ( i nt i = 1 ; i <= f a ; i ++) { f or ( i nt j = 1 ; j <= ca ; j ++) {
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
i f ( A[ i ] [ j ] == mi n_a) A[ i ] [ j ] =max_b; } } / / par a i nt er cambi ar l os maxi mos de con l os mi ni mos de A f or ( i nt i = 1 ; i <= f b ; i ++) { f or ( i nt j = 1 ; j <= cb ; j ++) { i f ( B[ i ] [ j ] == max_b) B[ i ] [ j ] =mi n_a; } } } i nt mai n ( ) { i nt A [ 20] [ 20] ; i nt B [ 20] [ 20] ; i nt f a, ca, f b, c b; pr i nt f ( " I ns er t f i l as de pr i nt f ( "I nser t col umnas pr i nt f ( " I ns er t f i l as de pr i nt f ( "I nser t col umnas
A: de B: de
" ) ; s canf ( " %d" , &f a) ; A: ") ; scanf ( "%d", &ca) ; " ) ; s canf ( " %d" , &f b) ; B: ") ; scanf ( "%d", &cb) ;
/ / l ect ur a de mat r i ces pr i nt f ( " \ nI NSERTANDO DATOS EN MATRI S A: \ n") ; l l enar ( A, f a, c a) ; pr i nt f ( " \ nI NSERTANDO DATOS EN MATRI S B: \ n") ; l l enar ( B, f b, c b) ; pr i nt f ( " \ nMATRI CES ORI GI NALMENTE I NSERTADAS: " ) ; most r ar ( A, f a, ca) ; pr i nt f ( " \ n" ) ; most r ar ( B, f b, cb) ; pr i nt f ( " \ n" ) ; / / i nt ercambi ando el ement os i nt er cambi ar ( A, f a, ca, B, f b, cb) ; pr i nt f ( " \ nMATRI CES DESPUES DEL I NTERCAMBI O: " ) ; most r ar ( A, f a, ca) ; pr i nt f ( " \ n" ) ; most r ar ( B, f b, cb) ; get ch( ) ; }
/*Dada una matris cuadrada invertir su diagonal principal*/
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { f or ( i nt j = 1 ; j <= d ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most r ar ( i nt M[ 20] [ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) {
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= d ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d i nvi er t e { i nt f i n = d; f or ( i nt i = { i nt aux = M M [i ] [ i ] = M [ d] [ d] = f i n- - ; } }
( i nt M[ 20] [ 20] , i nt d) 1 ; i <= d / 2 ; i ++) [i ] [ i ]; M [ d] [ d] ; aux;
i nt mai n( ) { i nt M [ 20] [ 20] ; i nt d; pr i nt f ( "I nser t e di men. de l a mat r i s cuadr ada: ") ; scanf ( " %d" , &d) ; l l enar ( M, d) ; pr i nt f ( "\ nMATRI S ORI GI NAL: ") ; most r ar ( M, d) ; pr i nt f ( " \ n\ nMATRI S CON LA DI AGONAL PRI NCI PAL I NVERTI DA: " ) ; i nvi er t e ( M, d) ; most r ar ( M, d) ; get ch( ) ; }
/*Dada una matris cuadrada invertir su diagonal secundaria*/
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { f or ( i nt j = 1 ; j <= d ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most r ar ( i nt M[ 20] [ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= d ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d i nvi er t e ( i nt M[ 20] [ 20] , i nt d) { i nt f i n = d; f or ( i nt i = 1 ; i <= d / 2 ; i ++)
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
{ i nt aux = M [ i ] [ d] ; M [ i ] [ d] = M [ d] [ i ] ; M [ d] [ i ] = aux; f i n- - ; } } i nt mai n( ) { i nt M [ 20] [ 20] ; i nt d; pr i nt f ( "I nser t e di men. de l a mat r i s cuadr ada: ") ; scanf ( " %d" , &d) ; l l enar ( M, d) ; pr i nt f ( "\ nMATRI S ORI GI NAL: ") ; most r ar ( M, d) ; pr i nt f ( " \ n\ nMATRI S CON LA DI AGONAL SECUNDARI A I NVERTI DA: " ) ; i nvi er t e ( M, d) ; most r ar ( M, d) ; get ch( ) ; }
/*Dada dos matrices de diferentes tamanios R y S mostrar los elementos comunes de R en S*/
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most rar ( i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d c omunes ( i nt R[ 20] [ 20] , i nt f r , i nt c r , i nt S[ 20] [ 20] , i nt f s , i nt c { pr i nt f ( " \ n\ nLos el ement os comunes de R en S son: " ) ; f or ( i nt i = 1 ; i <= f r ; i ++) { f or ( i nt j = 1 ; j <= cr ; j ++) { f or ( i nt k = 1 ; k <= f s ; k++) { f or ( i nt l = 1 ; l <= cs ; l ++) { i f ( R [ i ] [ j ] == S [ k ] [ l ] ) pr i nt f ( " [ %d] " , R [ i ] [ j ] ) ;
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
} } } } } i nt mai n( ) { i nt R [ 20] [ 20] ; i nt S [ 20] [ 20] ; i nt f r , cr , f s , cs; pr i nt f ( " I ns er t e f i l as de scanf ( "%d", &f r ) ; pr i nt f ( "I nser t e col umnas scanf ( "%d", &cr ) ; pr i nt f ( " I ns er t e f i l as de scanf ( "%d", &f s) ; pr i nt f ( "I nser t e col umnas scanf ( " %d" , &cs) ;
R: " ) ; de R: ") ; S: " ) ; de S: ") ;
pri nt f ( " \ nLLENANDO MATRI S R: \ n") ; l l enar ( R, f r , cr ) ; pr i nt f ( " \ nLLENANDO MATRI S S: \ n") ; l l enar ( S, f s , c s ) ; pr i nt f ( "\ nLA MATRI S R : ") ; mos t r ar ( R, f r , c r ) ; pr i nt f ( "\ n\ nLA MATRI S S : ") ; mos t r ar ( S, f s , c s) ; c omunes ( R, f r , c r , S, f s , c s) ; get ch( ) ; }
/*Intercambiar los datos de la columna 1 con la ultima columna*/
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos : [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most rar ( i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d i nt ercambi ar ( i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) {
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
i nt aux = M [ i ] [ 1] ; M [ i ] [ 1] = M [ i ] [ c ] ; M [ i ] [ c ] = aux; } } i nt mai n ( ) { i nt M [ 20] [ 20] ; i nt f , c; pr i nt f ( " I ns er t e f i l as de l a mat r i s : " ) ; scanf ( "%d", &f ) ; pr i nt f ( "I nser t e col umnas de l a mat r i s: ") ; scanf ( " %d" , &c) ; pr i nt f ( "\ nLLENANDO MATRI S : \ n") ; l l enar ( M, f , c) ; pr i nt f ( "\ nLA MATRI S ORI GI NAL : ") ; most r ar ( M, f , c); pri nt f ( " \ n\ nLA MATRI CES I NTERCAMBI ADA : " ) ; i nt er cambi ar ( M, f , c); most r ar ( M, f , c); get ch( ) ; }
/* Contar el numero de digitos de cada elemento de una matris */
Código: #i ncl ude #i ncl ude voi d l l enar ( i nt M [ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d mos t r ar ( i nt M [ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d cuent a ( i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { i nt cont ador = 0; i nt n=M[ i ] [ j ] ; whi l e ( n ! = 0) { n = n / 10;
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
cont ador ++; } pr i nt f ( " \ n[ %d] t i ene: %d di gi t o( s ) " , M[ i ] [ j ] , c ont ador ) ; } } } i nt mai n ( ) { i nt M [ 20] [ 20] ; i nt f , c; pr i nt f ( " I ns er t e f i l as de l a mat r i s : " ) ; scanf ( "%d", &f ) ; pr i nt f ( "I nser t e col umnas de l a mat r i s: ") ; scanf ( " %d" , &c) ; pri nt f ( " \ nLLENANDO MATRI S M: \ n" ) ; l l enar ( M, f , c) ; pr i nt f ( "\ nLA MATRI S: ") ; most r ar ( M, f , c); pr i nt f ( "\ n\ nCONTEO DE DI GI TOS: " ) ; cuent a (M, f , c); get ch( ) ; }
/*Hallar la fila y la columna del primer elemento "e" */
Código: #i ncl ude #i ncl ude voi d l l enar Mat r i s ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most rarMat r i s (i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d busqueda ( i nt M[ 20] [ 20] , i nt f , i nt c, i nt e) { i nt bn = 0; f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { i f ( M [ i ] [ j ] == e) { pr i nt f ( " \ nEl numero: %d se encuent r a en l a posi ci on: [ %d] [ %d] de l a bn = 1;
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
} } } i f ( bn == 0) pr i nt f ( "\ nNo se encont r o el numero %d en l a matr i s : ( ", e); } i nt mai n ( ) { i nt M [ 20] [ 20] ; i nt f , c, numer o; pr i nt f ( " I ns er t e f i l as de l a mat r i s : " ) ; scanf ( "%d", &f ) ; pr i nt f ( "I nser t e col umnas de l a mat r i s: ") ; scanf ( " %d" , &c) ; pr i nt f ( "\ nLLENANDO MATRI S: \ n" ) ; l l enar Mat r i s ( M, f , c ) ; pr i nt f ( "\ nLA MATRI Z Z: ") ; most r ar Mat r i s ( M, f , c); pr i nt f ( "\ n\ nI nser t e un numer o: ") ; sc anf ( " %d", &numer o) ; busqueda ( M, f , c, numer o) ; get ch( ) ; }
En línea [www.darvein.org] Darvein
Desconectado Mensajes: 182
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #4 en: 26 Febrero 2008, 18:45 »
>> MATRICES y VECTORES<< /* Dada una matris y un vector, contar la cantidad de numeros primos de ambos */
Código: =)
#i ncl ude #i ncl ude voi d l l enar Mat r i s ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most rarMat r i s (i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) } }
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
} voi d l l enar Vector ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " I ns er t e pos . [ %d] : " , i ) ; scanf ( "%d", &V [ i ] ) ; } } voi d most r ar Vect or ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " [ %d] " , V [ i ] ) ; } } i nt pr i mos Mat r i s ( i nt M[ 20] [ 20] , i nt f , i nt c ) { i nt cant = 0; f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { i nt cc = 0; f or ( i nt k = 1 ; k <= M [ i ] [ j ] ; k++) { i f ( M [ i ] [ j ] % k == 0) cc++; } i f ( cc == 2) cant ++; } } return (cant); } i nt pr i mosVector ( i nt V[ 20] , i nt d) { i nt cant = 0; f or ( i nt i = 1 ; i <= d ; i ++) { i nt c = 0; f or ( i nt j = 1 ; j <= V [ i ] ; j ++) { i f ( V [ i ] % j == 0) c++; } i f ( c == 2) cant ++; } return (cant); }
i nt mai n( ) { i nt M [ 20] [ 20] ; i nt V [ 20] ; i nt f , c, d; pr i nt f ( " I ns er t e f i l as de l a mat r i s : " ) ; scanf ( "%d", &f ) ; pr i nt f ( "I nser t e col umnas de l a mat r i s: ") ;
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
scanf ( " %d" , &c) ; pr i nt f ( "I nser t e di mensi on del vector: ") ; scanf ( " %d" , &d) ; pr i nt f ( "\ nLLENANDO MATRI S: \ n" ) ; l l enar Mat r i s ( M, f , c ) ; pri nt f ( " \ nLLENANDO EL VECTOR: \ n") ; l l enar Vector ( V, d) ; pr i nt f ( "\ nLA MATRI S: ") ; most r ar Mat r i s ( M, f , c); pr i nt f ( "\ n\ nEL VECTOR: \ n") ; mostr arVect or ( V, d) ; i nt pr i mos = pr i mosMatr i s ( M, f , c) + pr i mosVect or ( V, d) ; pr i nt f ( " \ n\ nLA CANTI DAD DE NUMEROS PRI MOS QUE HAY EN LOS ARREGLOS ES: get ch( ) ; }
/*Dada la matrix de m*n y el vector de tamanio n, determinar que columna de la matris es igual al vector*/
Código: #i ncl ude #i ncl ude voi d l l enar Mat r i s ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } } voi d most rarMat r i s (i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d l l enar Vector ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " I ns er t e pos . [ %d] : " , i ) ; scanf ( "%d", &V [ i ] ) ; } } voi d most r ar Vect or ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " [ %d] " , V [ i ] ) ; }
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
} voi d pr o cedur e ( i nt M[ 20] [ 20] , i nt f , i nt c , i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= f ; i ++) { i nt sw = 1; f or ( i nt j = 1 ; j <= c ; j ++) { f or ( i nt k = 1 ; k <= d ; k++) { i f ( M [ j ] [ i ] ! = V [ k] ) sw = 0; } } i f ( sw == 1) pr i nt f ( "\ n\ nLa col umna %d es i gual al vect or ", i ) ; } }
i nt mai n ( ) { i nt M [ 20] [ 20] ; i nt V [ 20] ; i nt f , d; pr i nt f ( " I ns er t e f i l as de l a mat r i s : " ) ; scanf ( "%d", &f ) ; pr i nt f ( "I nser t e di mensi on del vector: ") ; scanf ( " %d" , &d) ; pr i nt f ( "\ nLLENANDO MATRI S: \ n" ) ; l l enar Mat r i s ( M, f , d) ; pri nt f ( " \ nLLENANDO EL VECTOR: \ n") ; l l enar Vector ( V, d) ; pr i nt f ( "\ nLA MATRI S: ") ; most r ar Mat r i s ( M, f , d) ; pr i nt f ( "\ n\ nEL VECTOR: \ n") ; mostr arVect or ( V, d) ; pr ocedur e ( M, f , d, V, d) ; get ch( ) ; }
/*Dada una matris Z almacenar en un vector A la suma por sus columnas y en un vector B la suma por sus filas */
Código: #i ncl ude #i ncl ude voi d l l enar Mat r i s ( i nt M[ 20] [ 20] , i nt f , i nt c ) { f or ( i nt i = 1 ; i <= f ; i ++) { f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " I ns er t e pos [ %d] [ %d] : " , i , j ) ; s canf ( " %d" , &M [ i ] [ j ] ) ; } } }
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
voi d most rarMat r i s (i nt M[ 20] [ 20] , i nt f , i nt c) { f or ( i nt i = 1 ; i <= f ; i ++) { pr i nt f ( " \ n" ) ; f or ( i nt j = 1 ; j <= c ; j ++) { pr i nt f ( " [ %d] " , M [ i ] [ j ] ) ; } } } voi d l l enar Vector ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " I ns er t e pos . [ %d] : " , i ) ; scanf ( "%d", &V [ i ] ) ; } } voi d most r ar Vect or ( i nt V[ 20] , i nt d) { f or ( i nt i = 1 ; i <= d ; i ++) { pr i nt f ( " [ %d] " , V [ i ] ) ; } } voi d vec t or A ( i nt M[ 20] [ 20] , i nt f , i nt c , i nt A[ 20] , i nt d) { f or ( i nt i = 1 ; i <= f ; i ++) { i nt suma = 0; f or ( i nt j = 1 ; j <= c ; j ++) { suma = suma + M [ j ] [ i ] ; } A [ i ] = suma; } } voi d vec t or B ( i nt M[ 20] [ 20] , i nt f , i nt c , i nt B[ 20] , i nt d) { f or ( i nt i = 1 ; i <= f ; i ++) { i nt suma = 0; f or ( i nt j = 1 ; j <= c ; j ++) { suma = suma + M [ i ] [ j ] ; } B [ i ] = suma; } } i nt mai n ( ) { i nt Z [ 20] [ 20] ; i nt A [ 20] ; i nt B [ 20] ; i nt f , c; pr i nt f ( " I ns er t e f i l as de l a mat r i s : " ) ; scanf ( "%d", &f ) ; pr i nt f ( "I nser t e col umnas de l a mat r i s: ") ; scanf ( " %d" , &c) ;
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
pr i nt f ( "\ nLLENANDO MATRI S: \ n" ) ; l l enar Mat r i s ( Z, f , c ) ; pr i nt f ( "\ nLA MATRI Z Z: ") ; most r ar Mat r i s (Z, f , c); pr i nt f ( " \ n\ nSUMA vec t or A ( Z, f , c , mostr arVect or ( A, pr i nt f ( "\ n\ nSUMA vec t or B ( Z, f , c , most r ar Vect or ( B, get ch( ) ; }
POR COLUMNAS DE LA MATRI S ( vect or A) : \ n") ; A, c ) ; c) ; POR FI LAS DE LA MATRI S ( vect or B) : \ n") ; B, f ) ; f);
En línea [www.darvein.org] darkness7977
Desconectado Mensajes: 34
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #5 en: 29 Febrero 2008, 00:47 »
hey...que bien y que casualidad recien en estos dias han iniciado la clase de progrmacion estructurada (apenas hoy comenzare a meterle mano al manual y al compilador) gracias por los codigos,me serviran para analizarlos En línea
Darvein
Desconectado
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #6 en: 29 Febrero 2008, 19:03 »
Citar gracias por los codigos,me serviran para analizarlos
Mensajes: 182 Tengo mas, luego los subire tengo sobre recurisividad, matrices, vectores, archivos, cadenas etc. xD =)
Que bueno saber que esos ejercicios le sirvio a alguien. En línea [www.darvein.org]
AxXioma
Desconectado Mensajes: 795
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #7 en: 29 Febrero 2008, 20:01 »
Gracias, buen aporte. En línea
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
Algunos pájaros no pueden ser enjaulados... .::Cuanto mas conocimiento adquieres, más te das cuenta del que hay a tu alrededor::. Sonex
Desconectado
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #8 en: 1 Marzo 2008, 15:04 »
Buenisimoo, muchas gracias
Mensajes: 350
En línea Darvein
Desconectado Mensajes: 182
=)
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #9 en: 1 Marzo 2008, 20:42 »
Citar holas me podrias poner problemas de prosesos secuenciales if elfe while switch
Todo lo que mencionas estan en los ejercicos. Aunque falta el switch, pero ya lo pondre En línea [www.darvein.org]
Darvein
Desconectado Mensajes: 182
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #10 en: 1 Marzo 2008, 20:47 »
Volví xD Aqui tambien hay ejercicios propuestos http://foro.elhacker.net/index.php/topic,34911.0.html
=) En línea [www.darvein.org]
Ejercicios resueltos C++ [programacion estructurada]
lifeguarda
Desconectado Mensajes: 5
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #11 en: 23 Septiembre 2008, 22:26 »
Como me ha dado por aprender c++ y he visto estos ejercicios como agradecimiento que mejor que compartir el curro que me he dao de meter estos ejercicios en un archivo con la solución de los ejercicios detrás... que si no las miramos antes http://rapidshare.com/files/147809362/Ejercicios.zip.html En línea
star09
Desconectado Mensajes: 1
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #12 en: 20 Mayo 2009, 00:45 »
holas queria preguntar como queda este programa en c++ es sobre funciones por valor y es sobre sacar los numeros primos En línea
Myth.ck
Desconectado
Re: Ejercicios resueltos C++ [programacion estructurada] « Respuesta #13 en: 20 Mayo 2009, 00:47 »
Cual? Dinos el problema y trataremos de solucionarlo
Mensajes: 305
Algorithmics & C++ Studient
En línea Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
camiloibarra6
Desconectado Mensajes: 1
ejercicos de c++ « Respuesta #14 en: 10 Octubre 2009, 19:37 »
hola!! estoy empezando a utilizar c++ y me a quedado muy dificil si alguien me ayuda con ejercicios que contengan count, shwitch o con un ejercicio que nunca pude hacer = decir un numero de una cifra, dividirlo entre 3, imprimir la division si es decimal y si es entero mostrar division entera"
gracias
Ejercicios resueltos C++ [programacion estructurada]
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_e...
En línea Páginas: [1] 2
Ir a:
ir
===> Ejercicios
Mensajes similares
Asunto
Iniciado por
programas resueltos muy basicos Programación C/C++
dvaid
Respuestas Vistas Último mensaje 0
12 Agosto 2011, 2,935 14:55 por dvaid
Crackme's resueltos con IDA..... donde? Tinkipinki Ingeniería Inversa
3
801
23 Agosto 2011, 21:27 por apuromafo
Ejercicios resueltos de c o libro bien explicado
Fabi0lo
2
774
5 Mayo 2012, 18:24 por barnix456
wolfbcn
0
225
14 Junio 2012, 18:42 por wolfbcn
Programación C/C++
Resueltos robos de móviles que fotografiaban al ladrón Noticias
elotrolado ZonaPhotoshop Indejuegos ADSL InSecurity.Ro ISR Blog Uxio
lawebdegoku Yashira.org Seguridad Informática
MundoDivx Videojuegos Juegos de Mario Seguridad Wireless
Hispabyte Truzone indetectables.net Seguridad Colombia
Soluciones Web
ejemplos de
El Lado del Mal
thehackerway
Tienda Wifi
eNYe Sec
Internet móvil
Noticias Informatica
Underground México
Biblioteca de Seguridad Blog Administrador Sistemas
Todas las webs afiliadas están libres de publicidad engañosa.
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines