4/11/98:
Problemas de JAVA
------------------------- | Nombre | | Dirección | | Ciudad | | Teléfono | -------------------------con el menor número de instrucciones posible (1 punto).
2 b -4ac ------ 2a(1 punto).
52 % 10 Math.sqrt(4) 22 / 7 22 / 7f 4 - 3 / 4 - 3(1 punto).
int i, j, k; max = 10 ; double x = 1; double K = 1,000; static int Premio = 50; static int 2doPremio = 25; int horaLocal = 4.30; static double x = 6;(1 punto).
for (int star = 9; star<0; star++) System.out.print('*');(1 punto).
4****+donde cada línea contiene un número, tantos asteriscos como indica el número, y un signo +. Para ello se ha escrito el siguiente programa:
int numero; for (numero = 1; numero<5; numero++) System.out.print(numero); for (int aster = 1; aster<numero; aster++) System.out.println(aster); System.out.println('+');¿Qué escribiría en realidad este programa? ¿Cómo habría que corregirlo para que haga lo que se desea? (2 puntos).
void print() { System.out.println("---------------"+ "|"+nombre+"|"+ "|"+direccion+"|"+ "|"+ciudad+"|"+ "|"+telefono+"|"+ "---------------"); }
2 2.0 3 3.14... 1
max = 10 ; // No se da el tipo double K = 1,000; // Es 1.000 static int 2doPremio = 25; // Un identific.no puede empezar por 2 static double x = 6; // Variable duplicada
12341 2 3 4 +
int numero; for (numero = 1; numero<5; numero++) { System.out.print(numero); for (int aster = 1; aster<numero; aster++) System.out.print("*"); System.out.println('+'); }
for (int i=1900; i<2000; i+=10) System.out.print(i+" "); System.out.println("");
16/12/98:
Problemas de Smalltalk
| x | x:=SortedCollection with: 'abcd' with: 'mnop' with: 'cdef' with: 'cddd'. x select: [ :i | i at: 1 = $c ] asSortedCollection: [ :i :j | i>j]
| x | x:=SortedCollection with: 'abcd' with: 'mnop' with: 'cdef' with: 'cddd'. (x select: [ :i | (i at: 1) = $c ]) asSortedCollection: [ :i :j | i>j]
busquedaBinariaDe: x desde: izq hasta: der "Programa de búsqueda binaria en una colección ordenada" | centro | izq=der ifTrue: [ x=(self at: izq) ifTrue: [^izq] ifFalse: [^0] ] ifFalse: [ centro := izq+der//2. x=(self at: centro) ifTrue: [^centro] ifFalse: [ x<(self at: centro) ifTrue: [ ^self busquedaBinariaDe: x desde: izq hasta: centro ] ifFalse: [ ^self busquedaBinariaDe: x desde: centro+1 hasta: der ] ] ]
5/2/99:
A) Problemas de análisis y diseño
Se pide:
Se pide:
B) Problemas de SMALLTALK
a) (#(1 'abc' #Juan) class with: 2 with: "abcd") at: 2 b) (#(1 #(2 3) 4) at: 2) at: 2 + 1 c) | x | x:=7. 5 < x ifTrue: [ x < 8 ifTrue: [ x = 6 ifTrue: [ x:=2*x ] ifFalse: [ x:=2*x+1 ]] ifFalse: [ x:=2*x-1 ] ifFalse: [ x=x//2 ] ] d) | x | x:=SortedCollection with: 'abcd' with: 'mncp' with: 'cdcf' with: 'cddd'. x select: [ :i | i at: 3 = $c ] asSortedCollection: [ :i :j | i>j] e) | a b | a:=Array new: 2. a at: 1 put: #('abcd' #(2 3)). b:=Array new: 2. b at: 1 put: 2. b at: 2 put: a at: 1 at: 2. a at: 2 put: b. a
C) Problemas de JAVA
class TryTry { public static void main(String[] args) { try { if (args.length==0) throw 5; else throw "abcd"; } catch (int n) { System.out.println("Error " + n); } catch (Object o) { System.out.println("Error " + o); } } }
Si este programa es correcto, explicar lo que hace. Si es incorrecto, explicar por qué. (1 punto).
D) Problemas de C++
Se supondrá que hay memoria suficiente para todo (no preocuparse de los fallos de memoria).
Añadir un programa principal que genere un objeto Bag de enteros e
introduzca varios enteros.
(2 puntos).
A) Problemas de análisis y diseño
Motor eléctrico (voltaje, potencia, velocidad, etc) Motor de corriente alterna ---------> Motor universal (frecuencia, etc) ^ (uso) Motor síncrono | Motor de inducción | (uso) | Motor de corriente continua ----------- Motor de imán permanente (inducción magnética, uso)
Motor eléctrico Motor de corriente alterna Motor síncrono Motor de inducción Motor universal alterno Motor de corriente continua Motor de imán permanente Motor universal continuo
Motor eléctrico Motor de corriente alterna Motor síncrono Motor de inducción Motor de corriente continua Motor de imán permanente Motor universal
Parado Arrancando En marcha (régimen permanente) Sobrecalentado
Pulsación del control de encendido/apagado Pulsación del botón de reset Activación del sensor interno de régimen permanente Activación del sensor interno de sobrecalentamiento
B) Problemas de SMALLTALK
a) (#(1 'abc' #Juan) class with: 2 with: 'abcd') at: 2 ^ ^ Resultado: 'abcd' b) ((#(1 #(2 3) 4) at: 2) at: 2) + 1 ^ ^ Resultado: 4 c) | x | x:=7. 5 < x ifTrue: [ x < 8 ifTrue: [ x = 6 ifTrue: [ x:=2*x ] ifFalse: [ x:=2*x+1 ]] ifFalse: [ x:=2*x- 1 ] ] ifFalse: [ x:=x//2 ] ^ ^ ^ ^ Resultado: 15 d) | x | x:=SortedCollection with: 'abcd' with: 'mncp' with: 'cdcf' with: 'cddd'. (x select: [ :i | (i at: 3) = $c ]) asSortedCollection: [ :i :j | i>=j] ^ ^ ^ ^ Resultado: SortedCollection ('mncp', 'cdcf', 'abcd') e) | a b | a:=Array new: 2. a at: 1 put: #('abcd' #(2 3)). b:=Array new: 2. b at: 1 put: 2. b at: 2 put: ((a at: 1) at: 2). ^^ ^ ^ a at: 2 put: b. a Resultado: Array (('abcd' (2 3)) (2 (2 3)))
Variables de objeto: filas, columnas, datos. Método de clase: new: aNumber1 new: aNumber2 "Crea una matriz" |x| x:=Matriz new. "Crea el objeto con el constructor por defecto" x new: aNumber1 new: aNumber2. "Lanza el método de objeto" ^x "Devuelve el objeto" Método de objeto: new: aNumber1 new: aNumber2 "Asigna valores a las variables de objeto" filas := aNumber1. columnas := aNumber2. datos := Array new: filas. "Da estructura a los datos" 1 to: filas do: [:i|datos at: i put: (Array new: columnas)]
C) Problemas de JAVA
/* Aplicación/applet */ import java.applet.Applet; import java.awt.Graphics; public class HelloWorld2 extends Applet { public static void main(String[] args) { System.out.println("¡Hola, Mundo!"); // Display the string } public void paint(Graphics g) { g.drawString("¡Hola, mundo!", 50, 25); } }