|
Thursday, February 28, 2019
Dispositius d'emmagatzematge
Wednesday, February 20, 2019
Numbers in an interval
Write a program that reads two numbers a and b, and prints all numbers between a and b.
Input: Input consists of two natural numbers a and b.
Output: Print a line with a, a+1,…, b−1, b. Separate the numbers with commas.
Input: Input consists of two natural numbers a and b.
Output: Print a line with a, a+1,…, b−1, b. Separate the numbers with commas.
#include <iostream> using namespace std; int main () { int x, y; cin >> x >> y; bool primera=true; for (int i =x; i<=y; ++i) { if (primera) primera=false; else cout << ','; cout << i; } cout << endl; }
First numbers
Write a program that reads a number n, and prints all numbers between 0 and n.
Input: Input consists of a natural number n.
Output: Print in order all natural numbers between 0 and n.
Input: Input consists of a natural number n.
Output: Print in order all natural numbers between 0 and n.
#include <iostream> using namespace std; int main (){ int n; cin >> n; int i = 0; while (i <= n) { cout << i << endl; ++i; } }
Leap Years
Write a program that tells if a year is or is not a leap year.
A leap year has 366 days. After the Gregorian reform, the leap years are those multiple of four that do not end with two zeros, and also the years ending with two zeros such that, after removing these two zeros, are divisible by four. Thus, 1800 and 1900, although being multiples of four, were not leap years; by contrast, 2000 was a leap year.
Input: Input consists of a natural number between 1800 and 9999.
Output: If the year is a leap year, print “YES”; otherwise print “NO”.
A leap year has 366 days. After the Gregorian reform, the leap years are those multiple of four that do not end with two zeros, and also the years ending with two zeros such that, after removing these two zeros, are divisible by four. Thus, 1800 and 1900, although being multiples of four, were not leap years; by contrast, 2000 was a leap year.
Input: Input consists of a natural number between 1800 and 9999.
Output: If the year is a leap year, print “YES”; otherwise print “NO”.
#include <iostream> using namespace std; int main () { int a; cin >> a; if (a%100 == 0) { int n; n=a/100; if(n%4== 0) cout << "YES" << endl; else cout << "NO" << endl; } else if (a%4 ==0) cout << "YES" << endl; else cout << "NO" << endl; }
Time decomposition
Write a program that, given a number of seconds n, prints the number of hours, minutes and seconds represented by n.
Input: Input consists of a natural number n.
Output: Print three natural numbers h, m, s such that 3600h+60m+s=n, with m<60 and s<60.
Input: Input consists of a natural number n.
Output: Print three natural numbers h, m, s such that 3600h+60m+s=n, with m<60 and s<60.
#include <iostream> using namespace std; int main (){ int n; cin >> n; int h, m, s; h = n/3600; s = n%60; m = (n-s-(3600*h))/60; cout << h <<' '<< m << ' ' << s << endl; }
Monday, February 18, 2019
Topologías de red (ventajas y desventajas)
- Facilidad de implementación y crecimiento.
- Es la más económica.
- Fallada de un nodo no afecta la resta.
- Es una red que no ocupa mucho espacio.
Desventajas:
- Difícil de administrar.
- El rendimiento disminuye cuando añadimos más nodos.
- La fallada en el bus es difícil de detectar.
- Limitación de las longitudes físicas del canal.
- Un problema en el canal usualmente degrada toda la red.
Ventajas :
- El sistema provee un acceso equitativo para todas las computadoras.
- El rendimiento no decae cuando muchos usuarios utilizan la red.
- Fácil de detectar las falladas.
- Arquitectura muy sólida.
Desventajas:
- Longitudes de canales (si una estación desea enviar a otra, los datos tendrán que pasar por todas las estaciones intermedias antes de alcanzar la estación de destino).
- El canal usualmente se degradara a medida que la red crece.
- Difícil de encontrar y reparar los problemas.
- La transmisión de datos es más lenta ya que la información debe pasar por todas las estaciones intermedias antes de llegar al destino.
Ventajas :
- Facilidad de resolución de problemas.
- Mucho más rápida.
Desventajas:
- Se requiere mucho cable.
- Si se cae el segmento principal todo el segmento también cae.
- Es más difícil su configuración.
- Si se llegara a desconectar un nodo, todos los que están conectados a él se desconectan también.
Ventajas :
- Es sencillo de implementar y crecimiento.
- Económica.
- La fallada de un nodo no afecta a la resta.
- Fácil de administrar.
- Facilidad para detectar las falladas.
Desventajas:
- Longitud de cable y nombre de estaciones es limitado.
- Coste de administración es cara a largo plazo.
- El rendimiento se disminuye a añadir más nodos.
- La fallada de nodo central deshabilita toda la red.
Ventajas :
- Es posible llevar los mensajes de un nodo a otro por diferentes caminos.
- Cada servidor tiene sus propias comunicaciones con todos los demás servidores.
- Si falla un cable el otro se hará cargo del tráfico.
- Si un nodo desaparece o falla no afecta en absoluto a los demás nodos.
- Si desaparece no afecta tanto a los nodos de redes.
Desventajas:
- El costo de la red puede aumentar en los casos en los que se implemente de forma alambica, la topología de red y las características de la misma implican el uso de más recursos.
- En el caso de implementar una red en malla para atención de emergencias en ciudades con densidad poblacional de más de 5000 habitantes por kilómetro cuadrado, la disponibilidad del ancho de banda puede verse afectada por la cantidad de usuarios que hacen uso de la red simultáneamente; para entregar un ancho de banda que garantice la tasa de datos en demanda y, que en particular, garantice las comunicaciones entre organismos de rescate, es necesario instalar más puntos de acceso, por tanto, se incrementan los costos de implementación y puesta en marcha.
Subscribe to:
Posts (Atom)
Modelo OSI
Open System Interconnection , Interconexión de Sistemas Abiertos, es un modelo para estudiar las categorías en que se pueden dividir los pr...

-
Write a program that reads two numbers and prints their minimum. Input: Input consists of two integer numbers. Output: Print a l...
-
Write a program that reads three numbers and prints the sum of their minimum and maximum values. Input : Input consists of three integ...
-
Respon els següents cassos finals relacionats amb vacances, permisos retribuïts i calendari laboral. El Guillem se sent perjudicat ...