Mostrando entradas con la etiqueta algoritmo. Mostrar todas las entradas
Mostrando entradas con la etiqueta algoritmo. Mostrar todas las entradas

sábado, 21 de febrero de 2015

Algoritmo - Factorial de un número en C++ – Hipotecario – Settlement –Donate – Online – Shipping – Culture

factorial

Muchas veces en matemáticas, estadística y áreas afines debemos obtener elfactorial de un número. El factorial de n se define como n! = n*(n - 1)*(n - 2)*(n - 3)!... Donde n es un número natural cualquiera (n = 0), ejemplo: 4! = 4*3*2*1 = 24.

Por definición 0! = 1

Ahora, veamos como obtener el factorial de un número mediante un algoritmo enc++.

#include iostream

using namespace std;

int main(){
int numero,factorial = 1;
cout "Ingrese el número que desea saber el factorial \n";
cin numero;
while(numero){
factorial = factorial * numero;
numero--;
}
cout "El factorial es: " factorial endl;
}

Explicación:

-Declaramos 2 variables de tipo entero, una llamadanúmero la cual almacenará el valor leído por teclado que será el número que deseamos saber su factorial.
-La segunda variable llamadafactorial la inicializaremos en 1, esto debido a que sí deseamos saber el factorial de 0, lo que está programado dentro del while no se ejecutará(0 es como decir false en valor booleano) y por definición el factorial de 0 es 1.
-Al ingresar al while el verificará el valor de la variablenumero, sí este es cualquier valor excepto 0 entonces se ejecutará.
-La variablefactorial dentro del while cumplirá el rol de un acumulador. Imaginemos el proceso... Sí deseamos saber el factorial de 4, este número es distinto de 0, por lo cual entrará en el while, la variablefactorial tiene en este momento el valor de 1, pero este valor será remplazado por 1 * 4 (factorial = 1 * 4).
-Luego, el valor de 4 disminuirá a 3 con la instrucciónnumero-- y de nuevo el while comprobará la condición, al ser 3 entrará de nuevo y realizará la operación del acumuladorfactorial, ahora tomando el valor de 4 * 3 (factorial = 4 * 3). Esto se ejecutará hasta que la variable numero disminuya hasta el valor 0, posterior a esto arrojaremos un mensaje indicando el factorial del número que hemos ingresado.


También te podría interesar:

  1. Matriz de la relación predecesor inmediato en c++
  2. Matriz de accesibilidad de un Digrafo en c++
  3. Elevar un número a una potencia en C++
  4. 4 Ejercicios Básicos de Programación Orientada a Objetos en c++
  5. De sistema decimal a sistema binario en c++ y Java


Auto Accident Attorney integrated ehr Car Insurance Quotes Best Criminal Lawyers in Arizona HOLLAND MICHIGAN COLLEGE structured settlement need cash now adverse remortgage Social media campaigns buyer of structured settlement annuity structered settlement sell annuity payment cheap auto insurance in va buy gift card los angeles motorcycle accident lawyer Adobe illustrator classes Donate Car to Charity California Casino Dallas Mesothelioma Attorneys Online casino Cheap Car Insurance in Virginia Criminal lawyer CAR INSURANCE QUOTES MN Claim personal injury lawyer sarasota fl Psd to WordPress See more at http//wwwginfostopnet/ car insurance quotes pa Mobile casino personal injury firm Casino reviews anti spam appliance paperport promotional code MASSAGE SCHOOL DALLAS TEXAS DONATE CAR FOR TAX CREDIT Mortgage Adviser Seo company WordPress hosting google adsense Mortgage Seo services new mexico mesothelioma lawyer personal injury law firm mesothelioma settlements Car Insurance in South Dakota structured settlement quote HARDDRIVE DATA RECOVERY SERVICES Insurance Forex Trading Platform Virtual Data Rooms Donating a Car in Maryland Forensics Online Course Proud Italian cook michigan motorcycle accident lawyer Italian cooking school los angeles auto accident attorneys DONATE CARS ILLINOIS Make money online Australia PHD on Counseling Education cash out annuity Php programmers DUI lawyer mesotheolima Hire php programmers mesothelioma attorneys california Donate car to charity California Register free domains Mesothelioma Law Firm phd in counseling education car accident lawyers west palm beach Live casino BEST CRIMINAL LAWYER IN ARIZONA what is structured settlement Hire php developers Photo Christmas cards structured settlement brokers business voip solutions Automobile Accident Attorney truck accident attorney los angeles Data Recovery Raid Dwi lawyer Webex Costs Car Insurance Quotes PA Met Auto Donating used cars to charity Royalty free images stock Computer science classes online Paperport promotional code meso lawyer selling structured settlement AUTO ACCIDENT ATTORNEY accident attorney in los angeles STRUCTURED ANNUITY SETTLEMENT How to Donate A Car in California Service business software Donate Cars in MA canada personals yahoo Learning adobe illustrator Criminal defense lawyer Php programmers for hire Nunavut Culture NUNAVUT CULTURE personal injury attorney springfield mo Hire php developer criminal defense federal lawyer Dayton Freight Lines asbestos lawyers injury lawyers Bankruptcy lawyer Personal Injury Law Firm Best social media platforms for business tennessee mesothelioma lawyer Seo companies motorcycle accident lawyer san francisco ONLINE COLLEDGES New social media platforms Business finance group caraccidentlawyer Online Criminal Justice Degree Dedicated Hosting Dedicated Server Hosting tucson car accident attorney Social media platforms for business Custom WordPress theme designer Best Seo company Business management software Personal Injury Lawyers Best social media platforms bus accident attorney los angeles Motor Replacements mesothelioma claims domains yahoo massage school dallas texas Online Christmas cards Custom Christmas cards WordPress themes for designers Html email Social media management LOW CREDIT LINE CREDIT CARDS mesothelioma law suits Business VOIP Solutions workers compensation lawyer los angeles buy structured settlements mesotheliama HOW TO DONATE A CAR IN CALIFORNIA car insurance quotes colorado domain registration yahoo Donate a car in Maryland Psychic for Free Social media examiner life insurance co lincoln DONATING USED CARS TO CHARITY Tech school SELL ANNUITY PAYMENT Neuson Donate a Car in Maryland structured settlement investments best accident attorneys Register Free Domains Holland Michigan College Social media platforms Christmas cards Donate Old Cars to Charity Psd to html WordPress theme designers structured settlement blog mesothelioma suit Social media strategies houston mesothelioma attorney ANNUITY SETTLEMENT Futuristic architecture Social media tools Online motor insurance quotes Donate Your Car for Kids MOTOR REPLACEMENTS Donate Car for Tax Credit Donate Your Car Sacramento DONATE YOUR CAR FOR MONEY hosted predictive dialers Sell Annuity Payment Online Classes mesothelioma lawyer houston Motor Insurance Quotes Asbestos Lawyers Email bulk service buying structured settlements Structures Annuity Settlement Car Insurance Quotes Colorado Annuity Settlements georgia truck accident lawyer Home Phone Internet Bundle Hard drive Data Recovery Services BETTER CONFERENCING CALLS Donate cars in ma Cheap Domain Registration Hosting mesothelioma attorney florida Donate Cars Illinois Criminal Defense Attorneys Florida illinois law lemon Car Insurance Quotes Utah Life Insurance Co Lincoln yahoo web hosting accident lawyers in los angeles Online Motor Insurance Quotes Online Colleges Paperport Promotional Code Injury Lawyers World Trade Center Footage Massage School Dallas Texas motorcycle accident attorney sacramento Low Credit Line Credit Cards Car Insurance Quotes MN Donate your Car for Money Cheap Auto Insurance in VA life insurance quotes small business administration sba attorney lawyer mesothelioma injury attorney baton rouge Forensics online course business email web hosting adverse credit remortgage la personal injury lawyer car insurance in south dakota Donating Used Cars to Charity CRIMINAL DEFENSE ATTORNEYS FLORIDA CHEAP DOMAIN REGISTRATION HOSTING truck accident attorney texas Royalty Free Images Stock Email Bulk Service mesothelioma lawyer asbestos cancer lawsuit Cheap Car Insurance for Ladies mortgage adviser NEUSON criminal defense attorneys florida Better Conference Calls Futuristic Architecture mesothelioma care WEBEX COSTS Car Donate Online College Course new york mesothelioma law firm Car Accident Lawyers online criminal justice degree Criminal lawyer Miami PHD IN COUNSELING EDUCATION mesothelioma drug Asbestos Lung Cancer holland michigan college personal injury lawyer MET AUTO Car Insurance Companies Insurance Companies

domingo, 31 de agosto de 2014

Matriz de la relación predecesor inmediato en c++. – Email – Lawyers – Law Firm – Registros

matriz de la relacion predecesor inmediato

Cuando aprendemos sobre reticulados nos enseñan un algoritmo para conseguir lamatriz de la relación de predecesores inmediatos de un CPO (Conjunto Parcialmente Ordenado) a partir de la matriz de la relación de orden [A,] donde A tiene n elementos.

El algoritmo sería el siguiente:

-Se calcula la matriz de la relación de orden M.

-Determinamos la matriz M = M- In . M es igual a la matriz de relación de orden menos la matriz identidad.

-Calculamos M^2 (M al cuadrado = MxM) haciendo una multiplicación binaria. Es decir, la matriz resultante solo contendrá unos y ceros como entradas.

-Hallamos M = M - M^2 (matriz de la relación predecesor inmediato). La matriz de la relación predecesor inmediato es igual a la matriz M menos la matriz M^2.

Ejercicio de ejemplo:

Dado el CPO [A, /] en dondeA = {200,60,30,10,5,1} y"/" es la relación binaria dedivisibilidad enA, (a/b si y sólo si "a" divide a "b") entonces: Hallar lamatriz de predecesores inmediatos.

Siguiendo el algoritmo calculamos la matriz M:
M=


1 divide a todo número real, por ello todas las entradas de esta fila de la matriz son 1.
5 divide a 5, 10, 30,60,200.
10 divide a 10,30,60,200.
30 divide a 30 y 60.
60 divide a 60.
200 divide a 200.

Siguiente paso, calculamos la matriz M que esta dada por M = M- In.

M=


In =


M = M- In

M =



Luego, calculamos M^2:

M^2 = M x M

X

M^2 =



Finalmente, hallamos la matriz de la relación predecesor inmediato.

M = M - M^2

M =





Una buena opción es desarrollar este algoritmo en algún lenguaje de programación que conozcamos, con el fin de aprender un poco más y a su vez comprobar los ejercicios que realizamos en nuestras horas de estudio. Este algoritmo lo podemos desarrollar enc++ de la siguiente forma:

#include iostream

using namespace std;

int main(){
int filas, colum;
cout "Ingrese la cantidad de filas de la matriz de la relación de orden: " endl;
cin filas;
cout "Ingrese la cantidad de columnas de la matriz de la relación de orden: " endl;
cin colum;
int matrizRO[filas][colum]; //matriz de relación de orden
int matrizRO2[filas][colum];
int matrizm2[filas][colum];
int matrizPI[filas][colum];
// Ingresamos las entradas de la matriz de relación de orden
cout "Ingrese las entradas de la matriz de la relación de orden" endl;
for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
cout "Ingrese la entrada a" i j endl;
cin matrizRO[i][j];
}
}
// Restamos la matriz identidad a nuestra matriz
for(int diagonal = 0; diagonal colum; diagonal++)
{
matrizRO[diagonal][diagonal] = 0;
}

//Imprimimos el valor de M

cout "Matriz M: " endl;
for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
cout matrizRO[i][j] " ";
}
cout endl;
}

//segunda matriz

for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
matrizRO2[i][j] = matrizRO[i][j];
}
}

//

//Calculamos M^2 (Binarizada)
for(int i=0;ifilas;i++){
for(int j=0;jcolum;j++){
matrizm2[i][j]=0;
for(int k=0;kcolum;k++){
if(matrizRO[i][k] == 1 and matrizRO2[k][j] == 1)
matrizm2[i][j] = 1;
}
}
}
// Imprimimos M^2
cout "Matriz M^2: " endl;
for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
cout matrizm2[i][j] " ";
}
cout endl;
}

//Calculamos la matriz de la relación predecesor inmediato

for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
matrizPI[i][j] = matrizRO[i][j] - matrizm2[i][j];
}
}

//Imprimimos la matriz de la relación predecesor inmediato

cout "Matriz de la relación predecesor inmediato: " endl;
for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
cout matrizPI[i][j] " ";
}
cout endl;
}

return 0;
}

int matrizRO[filas][colum]; //matriz de relación de orden
int matrizRO2[filas][colum];
int matrizm2[filas][colum];
int matrizPI[filas][colum];

La matrizRO representa la matriz de relación de orden, la matrizRO2 contiene las mismas entradas que la anterior, esta se usará solo para realizar la multiplicación para obtener M^2.
La matrizm2 representa la matriz M^2.
La matrizPI representa la matriz de la relación de predecesores inmediatos.

int filas, colum;
cout "Ingrese la cantidad de filas de la matriz de la relación de orden: " endl;
cin filas;
cout "Ingrese la cantidad de columnas de la matriz de la relación de orden: " endl;
cin colum;

Inicialmente ingresamos la cantidad de filas y columnas que tiene nuestra matriz. Dicha matriz es una matriz cuadrada de orden nxn.

// Restamos la matriz identidad a nuestra matriz
for(int diagonal = 0; diagonal colum; diagonal++)
{
matrizRO[diagonal][diagonal] = 0;
}

Para encontrar el valor de M solo debemos anular la diagonal principal de nuestra matriz.

//Calculamos M^2 (Binarizada)
for(int i=0;ifilas;i++){
for(int j=0;jcolum;j++){
matrizm2[i][j]=0;
for(int k=0;kcolum;k++){
if(matrizRO[i][k] == 1 and matrizRO2[k][j] == 1)
matrizm2[i][j] = 1;
}
}
}

Calculamos M^2 con el anterior algoritmo, tomar en cuenta que como es una matriz binarizada solo tendrá ceros y unos. Al conseguir una coincidencia de dos 1 almacenamos 1 en la matriz M^2.

//Calculamos la matriz de la relación predecesor inmediato

for(int i = 0; i filas; i++){
for(int j = 0; j colum; j++){
matrizPI[i][j] = matrizRO[i][j] - matrizm2[i][j];
}
}

Calculamos la matriz de la relación de predecesor inmediato con la diferencia entre la matriz M y M^2.

Resolviendo el ejercicio anterior con nuestro programa de consola hecho en c++, ésta sería su ejecución:

Ingrese la cantidad de filas de la matriz de la relación de orden:
6
Ingrese la cantidad de columnas de la matriz de la relación de orden:
6
Ingrese las entradas de la matriz de la relación de orden
Ingrese la entrada a00
1
Ingrese la entrada a01
1
Ingrese la entrada a02
1
Ingrese la entrada a03
1
Ingrese la entrada a04
1
Ingrese la entrada a05
1
Ingrese la entrada a10
0
Ingrese la entrada a11
1
Ingrese la entrada a12
1
Ingrese la entrada a13
1
Ingrese la entrada a14
1
Ingrese la entrada a15
1
Ingrese la entrada a20
0
Ingrese la entrada a21
0
Ingrese la entrada a22
1
Ingrese la entrada a23
1
Ingrese la entrada a24
1
Ingrese la entrada a25
1
Ingrese la entrada a30
0
Ingrese la entrada a31
0
Ingrese la entrada a32
0
Ingrese la entrada a33
1
Ingrese la entrada a34
1
Ingrese la entrada a35
0
Ingrese la entrada a40
0
Ingrese la entrada a41
0
Ingrese la entrada a42
0
Ingrese la entrada a43
0
Ingrese la entrada a44
1
Ingrese la entrada a45
0
Ingrese la entrada a50
0
Ingrese la entrada a51
0
Ingrese la entrada a52
0
Ingrese la entrada a53
0
Ingrese la entrada a54
0
Ingrese la entrada a55
1
Matriz M:
0 1 1 1 1 1
0 0 1 1 1 1
0 0 0 1 1 1
0 0 0 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0
Matriz M^2:
0 0 1 1 1 1
0 0 0 1 1 1
0 0 0 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
Matriz de la relación predecesor inmediato:
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 1
0 0 0 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0

Optimizando el algoritmo en c++:

El código fuente del algoritmo hecho en c++ está escrito con el mayor detalle posible con el fin de que pueda ser entendido fácilmente. Sin embargo, este puede ser optimizado evitando la creación de algunas matrices no tan necesarias y algunos ciclos repetitivos for. Esto con el fin de minimizar el tiempo de ejecución y reducir el espacio utilizado en la memoria.

#include iostream

using namespace std;

int main(){
int n;
char respuesta;
do{
cout "Ingrese el valor de n para su matriz de orden nxn " endl;
cin n;
int matrizR[n][n]; //matriz de relación de orden y luego de la relación predecesor inmediato.
int matrizm2[n][n];
// Ingresamos las entradas de la matriz de relación de orden
cout "Ingrese las entradas de la matriz de la relación de orden" endl;
for(int i = 0; i n; i++){
for(int j = 0; j n; j++){
cout "Ingrese la entrada a" i j endl;
cin matrizR[i][j];
//Anulando diagonal principal al momento de ingresar la matriz
if(i == j)
matrizR[i][j] = 0;
}
}

//Calculamos M^2 (Binarizada)
for(int i=0;in;i++){
for(int j=0;jn;j++){
matrizm2[i][j]=0;
for(int k=0;kn;k++){
if(matrizR[i][k] == 1 and matrizR[k][j] == 1){
matrizm2[i][j] = 1;
            break;
            }
}
}
}

//Calculamos la matriz de la relación predecesor inmediato y la imprimimos al mismo tiempo
cout "Matriz de la relación predecesor inmediato:" endl;
for(int i = 0; i n; i++){
for(int j = 0; j n; j++){
matrizR[i][j] = matrizR[i][j] - matrizm2[i][j];
cout matrizR[i][j] " ";
}
cout endl;
}
cout "Desea obtener una nueva matriz de la relación predecesor inmediato a partir de otra matriz de relación de orden? si = s no = n" endl;
cin respuesta;
}while(respuesta == 's');
return 0;
}

Inicialmente ingresamos el valor de n, la matriz de la relación de orden es una matriz cuadrada de orden nxn.

Mientras ingresamos las entradas o componentes de la matriz podemos ir anulando automática la diagonal principal, esto lo hacemos cuando los índices i y j son iguales.

if(i == j)
matrizR[i][j] = 0;

Para obtener la matriz M^2 solo necesitaremos conseguir un 1, recordemos que esta matriz debe estar binarizada. Por ello le agregamos el break al ciclo de manera que cuando encuentre un 1 salga del ciclo y no ejecute instrucciones innecesarias.

if(matrizR[i][k] == 1 and matrizR[k][j] == 1){
matrizm2[i][j] = 1;
break;
}

Al momento de obtener la matriz de la relación predecesor inmediato podemos guardar el resultado en la misma matriz inicial, además podemos ir imprimiendo los resultados en paralelo se van obteniendo.

for(int i = 0; i n; i++){
for(int j = 0; j n; j++){
matrizR[i][j] = matrizR[i][j] - matrizm2[i][j];
cout matrizR[i][j] " ";
}
cout endl;
}

Descarga del código fuente del proyecto:
http://www.mediafire.com/download/urr...


También te podría interesar:
4 Ejercicios Básicos de Programación Orientada a Objetos en c++
De sistema decimal a sistema binario en c++ y Java
3 libros sobre programacion orientada a objetos
[Ejercicio resuelto c++ POO Herencia Vectores MVC] Una Asociación de Lancheros trasladan turistas

injury lawyers west palm beach online motor insurance quotes Learning adobe illustrator Casino reviews Online casino Make money online Australia STRUCTURED ANNUITY SETTLEMENT Business management software structured settlement buyer semi truck accident lawyers asterisk call center software Asbestos Lawyers Bankruptcy lawyer ONLINE MOTOR INSURANCE QUOTES mesothelioma law suits CAR ACCIDENT LAWYERS best criminal lawyer in arizona Service business software Custom Christmas cards mesothelioma attorney florida Casino Donate car for tax credit Cheap Car Insurance in Virginia MORTGAGE ADVISER mesotheolima Business finance group Psd to html Massage school Dallas Texas Cheap Domain Registration Hosting what is structured settlement Car Insurance Quotes Utah MASSAGE SCHOOL DALLAS TEXAS student loan consolidation program Donate old cars to charity Online Motor Insurance Quotes Tech school Online Christmas cards Dwi lawyer Injury Lawyers structured settlement cash out fortis health insurance temporary Proud Italian cook Php programmers Forex Trading Platform Mobile casino ashely madis mesothelioma symptoms truck accident attorney los angeles sell annuity payment Donate Cars in MA Auto Mobile Insurance Quote cash out structured settlement Php programmers for hire Html email bus accident attorneys Photo Christmas cards car insurance quotes colorado Seo services PhD in counseling education car accident lawyers west palm beach Live casino DUI lawyer Hire php developers Psd to WordPress Car Insurance Quotes MN CRIMINAL DEFENSE ATTORNEYS FLORIDA workers compensation lawyer los angeles HARDDRIVE DATA RECOVERY SERVICES LIFE INSURANCE CO LINCOLN Computer science classes online Social media platforms for business Hire php programmers Criminal lawyer car donate Annuity Settlements ASBESTOS LAWYERS MET AUTO personal injury attorney springfield mo supportpeachtreecom Criminal defense lawyer Donate your Car for Money Hard drive Data Recovery Services benchmark lending Hire php developer Paperport Promotional Code Seo companies Asbestos Lung Cancer Best Criminal Lawyers in Arizona Seo company World Trade Center Footage Best social media platforms for business Custom WordPress theme designer New social media platforms canada personals yahoo Online Criminal Justice Degree life insurance quotes HOW TO DONATE A CAR IN CALIFORNIA buyer of structured settlement annuity mesothelioma lawyer dallas saskatchewan auto insurance yahoo web hosting ANNUITY SETTLEMENT houston tx auto insurance Donate Your Car for Kids Donating Used Cars to Charity colorado auto accident attorney Best Seo company mesothelioma ct How to donate a car in California best consolidation loan student Best social media platforms Social media examiner Psychic for Free Health Records Personal Health Record donating used cars to charity mesothelioma trial attorney Donate your car Sacramento cheap domain registration hosting mesothelioma lawsuit Adobe illustrator classes uk homeowner loans PAPERPORT PROMOTIONAL CODE Cheap Auto Insurance in VA CAR INSURANCE QUOTES MN CHEAP CAR INSURANCE IN VIRGINIA new mexico mesothelioma lawyer california motorcycle accident lawyer motor replacements WordPress themes for designers Car Insurance Quotes Colorado WordPress hosting accident attorney in los angeles PHD on Counseling Education bus accident attorney los angeles tucson car accident attorney motorcycle accident attorney chicago Social media management home phone internet bundle Social media platforms primary pulmonary hypertension Christmas cards FUTURISTIC ARCHITECTURE buying an annuity calculator CHEAP AUTO INSURANCE IN VA Neuson Motor Replacements Donating a car in Maryland phd in counseling education Donate a Car in Maryland Italian cooking school structured settlements companies See more at http//wwwginfostopnet/ email bulk service online criminal justice degree WordPress theme designers Social media strategies personal injury firm Social media tools Donate Car to Charity California auto accident attorney structured settlement purchasers Car Insurance in South Dakota Social media campaigns Mesothelioma Law Firm Donate Car for Tax Credit Forensics Online Course Online colledges car accident lawyer san bernardino dui lawyer scottsdale offshore accident lawyer Donate Your Car Sacramento How to Donate A Car in California Sell Annuity Payment Online motor insurance quotes Structures Annuity Settlement car insurance companies washington mesothelioma attorney adverse credit remortgage Nunavut Culture Dayton Freight Lines Insurance Companies Virtual Data Rooms best mesothelioma lawyers adverse remortgage Data Recovery Raid Donating a Car in Maryland Donate Cars Illinois Criminal Defense Attorneys Florida domain registration yahoo Business VOIP Solutions structured settlement sell DONATE CARS IN MA AUTOMOBILE ACCIDENT ATTORNEY motorcycle accident lawyer san francisco michigan motorcycle accident lawyer Life Insurance Co Lincoln earthlink business internet Motor replacements asbestos lawyers Holland Michigan College Online Colleges mesothelioma settlement amounts Automobile Accident Attorney Online Classes motor insurance quotes Royalty free images stock Car Insurance Companies Massage School Dallas Texas FORENSICS ONLINE COURSE Dedicated Hosting Dedicated Server Hosting Donate Old Cars to Charity Low Credit Line Credit Cards Cheap car insurance for ladies Car Insurance Quotes PA Dallas Mesothelioma Attorneys mesothelioma lawyer virginia accident car florida lawyer criminal defense federal lawyer selling my structured settlement asbestos lung cancer la personal injury lawyer CHEAP CAR INSURANCE FOR LADIES donate your car for kids Met Auto Home Phone Internet Bundle futuristic architecture NEUSON dallas mesothelioma lawyer royalty free images stock EMAIL BULK SERVICE illinois law lemon Royalty Free Images Stock Email Bulk Service MOTOR REPLACEMENTS Webex Costs Cheap Car Insurance for Ladies buy gift card Register free domains Register Free Domains car accident lawyers los angeles Better Conference Calls Futuristic Architecture Mortgage Adviser Car Donate register free domains DONATE CARS ILLINOIS Online College Course Auto Accident Attorney mesothelioma attorney assistance Car Accident Lawyers

Matriz de accesibilidad de un Digrafo en c++ – Virginia – Platform – cancer

digrafos en c++

ParaDigrafos existe un procedimiento para encontrar lamatriz de accesibilidad, podemos determinar la matriz de accesibilidad a través de una serie de pasos. La matriz de accesibilidad nos brinda información sobre si el digrafo es F.C (fuertemente conexo) o no, es decir si para cada par de vértices u,v:u es accesible desdev yv es accesible desdeu.
Al observar la matriz sí notamos que hay al menos un elemento igual a cero diremos que el digrafo no es F.C conexo. De lo contrario, si es F.C.

La matriz de accesibilidad de un Digrafo es:

Acc(D) = bin[In+ M+ M^2+ M^3+ ...+ M^n-1]

M es la matriz de conexión del digrafo, determinaremos M^2, M^3 hasta M^n-1donde n es el número de vértices del digrafo.

Luego de determinar las matrices antes mencionadas las sumaremos junto a la matriz identidad y ese resultado procederemos a binarizarlo (Los elementos mayores que 1 los haremos igual a 1, los elementos que sean igual a 0 seguirán siendo igual a 0).

Ejercicio de ejemplo:

Dada la matriz de conexión del siguiente digrafo, determinar su matriz de accesibilidad.

matriz de Digrafo

M=

matriz de Digrafo

M^2 = MxM

matriz de Digrafo

M^3 = M^2 * M

matriz de Digrafo

M^4 = M^3 * M

matriz de Digrafo

I5 =

matriz identidad

Acc(D) = bin[In+ M+ M^2+ M^3+ ...+ M^n-1]

Acc(D) =

matriz de accesibilidad de un digrafo

De esta manera podemos obtener la matriz de accesibilidad del digrafo. Este digrafo no es fuertemente conexo, debido a que su matriz de accesibilidad posee componentes nulas.

EnC++ Estos pasos para determinar sí el digrafo es F.C o no, los podemos realizar de la siguiente manera:

#include iostream

using namespace std;

int main(){
int vertices;
cout "Ingrese la cantidad de vertices del digrafo:" endl;
cin vertices;
int matrizC[vertices][vertices];
int matrizaux[vertices][vertices];
int matrizM[vertices][vertices];
int matrizAcc[vertices][vertices];
//Cargamos la matriz de conexion
cout "Ingrese los elementos de la matriz de conexion: " endl;
for(int i = 0; i vertices; i++){
for(int j = 0; j vertices; j++){
cout "Ingrese la entrada a" i j endl;
cin matrizC[i][j];
}
}

for(int i = 0; i vertices; i++){
for(int j = 0; j vertices; j++){
matrizaux[i][j] = matrizC[i][j];
matrizAcc[i][j] = matrizC[i][j];
}
}
//ciclo
int cont = vertices-2;
while(cont){
// Producto para M...
for(int i=0;ivertices;i++){
for(int j=0;jvertices;j++){
matrizM[i][j]=0;
for(int k=0;kvertices;k++){
matrizM[i][j]=matrizM[i][j]+(matrizC[i][k]*matrizaux[k][j]);
}
}
}
//Sumamos para la matriz de accesibilidad
for(int i = 0; i vertices; i++){
for(int j = 0; j vertices; j++){
matrizAcc[i][j] += matrizM[i][j];
matrizaux[i][j] = matrizM[i][j];
}
}
cont--;
}//Fin del ciclo

//Sumar matriz de indentidad y binarizar
for(int i = 0; i vertices; i++){
for(int j = 0; j vertices; j++){
if(i == j)
matrizAcc[i][j] = 1;
if(matrizAcc[i][j] 1)
matrizAcc[i][j] = 1;
}
}

//Imprimimos la matriz de accesibilidad
cout "Matriz de accesibilidad:" endl;
for(int i = 0; i vertices; i++){
for(int j = 0; j vertices; j++){
cout matrizAcc[i][j] " ";
}
cout endl;
}


return 0;
}

Inicialmente ingresamos el numero de vértices del digrafo, las matrices con las que vamos a trabajar son de orden nxn donde n es el numero de vértices del digrafo.
El ciclo while se repetirá mientras la variable cont sea distinta de 0 (n - 2 veces debido a que M^2 se calcula fuera del ciclo while), esta variable irá decreciendo de uno en uno en cada repetición del ciclo.
Mientras vamos realizando la multiplicación de las matrices vamos sumando los resultados en la matriz de accesibilidad.
Al final, luego de salir del ciclo sumamos la matriz identidad y binarizamos la matriz de accesibilidad.

Ejecución:

Ingrese la cantidad de vertices del digrafo:
5
Ingrese los elementos de la matriz de conexion:
Ingrese la entrada a00
0
Ingrese la entrada a01
1
Ingrese la entrada a02
0
Ingrese la entrada a03
0
Ingrese la entrada a04
0
Ingrese la entrada a10
1
Ingrese la entrada a11
0
Ingrese la entrada a12
1
Ingrese la entrada a13
0
Ingrese la entrada a14
1
Ingrese la entrada a20
0
Ingrese la entrada a21
0
Ingrese la entrada a22
0
Ingrese la entrada a23
0
Ingrese la entrada a24
0
Ingrese la entrada a30
0
Ingrese la entrada a31
1
Ingrese la entrada a32
0
Ingrese la entrada a33
0
Ingrese la entrada a34
0
Ingrese la entrada a40
0
Ingrese la entrada a41
1
Ingrese la entrada a42
1
Ingrese la entrada a43
1
Ingrese la entrada a44
0
Matriz de accesibilidad:
1 1 1 1 1
1 1 1 1 1
0 0 1 0 0
1 1 1 1 1
1 1 1 1 1

Descarga del proyecto en C++:
https://mega.co.nz/#!ZBETVRqK!eVh_8o...


También te podría interesar:
Algoritmo para calcular la matriz de la relación predecesor inmediato a partir de la matriz de la relación de orden en c++.
4 Ejercicios Básicos de Programación Orientada a Objetos en c++
eBook - Como programar en c++ Deitel
De sistema decimal a sistema binario en c++ y Java
3 libros sobre programacion orientada a objetos


BEST CRIMINAL LAWYER IN ARIZONA WordPress hosting car accident lawyers Criminal defense lawyer best consolidation loan student accident attorney in los angeles Car Insurance in South Dakota Business finance group Asbestos Lawyers CAR INSURANCE IN SOUTH DAKOTA asbestos lawyers personal injury accident lawyer Live casino Online casino Seo company Make money online Australia maritime lawyer houston Psychic for Free Php programmers for hire Donating a car in Maryland Hire php developer MESOTHELIOMA LAW FIRM Donate a Car in Maryland Online classes Casino Futuristic architecture donate your car for kids Service business software Mortgage cash out structured settlement selling annuity payments for cash Mobile casino Futuristic Architecture Donate Cars Illinois Criminal lawyer Injury Lawyers mesotheioma Hire php developers Best Criminal Lawyers in Arizona Best Seo company Webex Costs meso lawyer Casino reviews structured settlement cash out DUI lawyer Online Criminal Justice Degree donate old cars to charity adverse credit remortgage cheap car insurance in virginia Paperport Promotional Code Online College Course Best social media platforms for business mesothelioma compensation Hire php programmers WordPress themes for designers car insurance quotes mn st louis mesothelioma attorney Computer science classes online Online Stock Trading structured settlement brokers Car Donate Dwi lawyer saskatchewan auto insurance Social media examiner mesothelioma lawyer texas Cheap Car Insurance for Ladies Dallas Mesothelioma Attorneys Mesothelioma Law Firm Forensics Online Course Best social media platforms Donate cars in ma mesothelioma attorneys Car Accident Lawyers ASBESTOS LAWYERS mesothelioma drug mesothelioma attorney Car Insurance Quotes MN insurance medical temporary fast cash for house car insurance quotes pa peritoneal mesothelioma Social media platforms for business Automobile Accident Attorney Register free domains Cheap domain registration hosting alabama mesothelioma lawyer Bankruptcy lawyer DONATING A CAR IN MARYLAND mesothelioma attorney directory Donate Your Car for Kids better conferencing calls Social media campaigns CHEAP AUTO INSURANCE IN VA Motor Replacements New social media platforms Life insurance co Lincoln lease management software personal injury attorney springfield mo mesotheliama Php programmers anti spam exchange server Neuson Holland Michigan College Seo companies Criminal lawyer Miami Car Insurance Quotes Utah Donating Used Cars to Charity Custom Christmas cards business email web hosting criminal defense attorneys florida WordPress theme designers Custom WordPress theme designer Seo services domain registration yahoo Auto Mobile Shipping Quote Online Motor Insurance Quotes Business management software injury lawyers structured settlemen MORTGAGE ADVISER Online Christmas cards structured settlement quote buying structured settlements automobile accident attorney how to donate a car in california Dayton freight lines criminal defense federal lawyer seattle mesothelioma lawyer Photo Christmas cards florida car insurance company anti spam appliance STRUCTURED ANNUITY SETTLEMENT buy structured settlements BETTER CONFERENCING CALLS HARDDRIVE DATA RECOVERY SERVICES Car insurance quotes pa sell structured settlement calculator Donate Cars in MA Social media strategies michigan motorcycle accident lawyer Psd to WordPress AUTOMOBILE ACCIDENT ATTORNEY accident car florida lawyer structured settlement need cash now Html email Social media management Tech school Social media platforms Nunavut Culture Christmas cards Proud Italian cook buying an annuity calculator Psd to html cheap domain registration hosting DONATE CARS ILLINOIS HOME PHONE INTERNET BUNDLE Italian cooking school email bulk service HOW TO DONATE A CAR IN CALIFORNIA ONLINECLASSES sell your structured settlement payments Cheap Car Insurance in Virginia Dayton Freight Lines Adobe illustrator classes asbestos lung cancer home phone internet bundle Learning adobe illustrator Social media tools tennessee mesothelioma lawyer chicago hair laser removal mesotheolima Car insurance quotes MN motorcycle accident attorney sacramento Donate Car to Charity California Donate Car for Tax Credit Donate Your Car Sacramento How to Donate A Car in California phd in counseling education asbestos exposure lawyers Sell Annuity Payment hughes net business student loan consolidation program Structures Annuity Settlement most profitable internet business Car Insurance Quotes Colorado Annuity Settlements LIFE INSURANCE CO LINCOLN LOW CREDIT LINE CREDIT CARDS online colledges Hard drive Data Recovery Services Nunavut culture World Trade Center Footage holland michigan college pharmacist jobs in chicago car insurance companies Cheap Domain Registration Hosting Donating a Car in Maryland Criminal Defense Attorneys Florida miami personal injury attorney ONLINE MOTOR INSURANCE QUOTES mesothelioma law suits ashely madis Life Insurance Co Lincoln Auto Mobile Insurance Quote Best criminal lawyer in Arizona Online Colleges Online Classes Massage School Dallas Texas VIRTUAL DATA ROOMS wisconsin mesothelioma attorney Donate Old Cars to Charity motorcycle lawyer los angeles Low Credit Line Credit Cards buy gift card structured settlements annuities Donate your Car for Money Cheap Auto Insurance in VA Met Auto PHD on Counseling Education Donating used cars to charity Home Phone Internet Bundle ROYALTY FREE IMAGES STOCK dallas mesothelioma attorneys Forensics online course mesothelioma suit Car Insurance Quotes PA structured settlement company california mesothelioma attorney Royalty Free Images Stock mesothelioma charities Email Bulk Service Insurance Companies Insurance accident attorney orange county Donate cars Illinois personal injury lawyer Register Free Domains Better Conference Calls Mortgage Adviser injury lawyer houston tx domains yahoo city college in miami DONATE CARS IN MA Virtual Data Rooms best mesothelioma lawyers CAR INSURANCE QUOTES MN Auto Accident Attorney Data Recovery Raid la personal injury lawyer Motor Insurance Quotes

sábado, 31 de mayo de 2014

[Ejercicio resuelto Progranimate] Promedio de notas de una sección – Law Firm – Miami – Virtual


Planteamiento:
"Se conoce la cantidad de estudiantes de una sección y la nota de cada uno de ellos. Determinar el promedio de la sección."

Código fuente JavaScript:

script type="text/javascript"
//Program:Untitled

var cantidad = 0;
var i = 0;
var j = 0;
var nota = 0;
var AcumuladorNotas = 0;
var promedio = 0;

alert("Ingrese la cantidad de estudiantes de la sección");
cantidad = pronpt("","");

for ( i = 0 ; i cantidad ; i = i + 1 )
{
j = i + 1;
alert("Ingrese la nota numero " + j);
nota = pronpt("","");
AcumuladorNotas = AcumuladorNotas + nota ;
}//End For

promedio = AcumuladorNotas / cantidad ;
alert("El promedio de la sección es de: " + promedio);

//End of Program
/script

Diagrama de flujo:


Ejecución:

Ingrese la cantidad de estudiantes de la sección
5
Ingrese la nota numero 1
20
Ingrese la nota numero 2
11
Ingrese la nota numero 3
14
Ingrese la nota numero 4
17
Ingrese la nota numero 5
16
El promedio de la sección es de: 15.6


Casino workers compensation lawyer los angeles CAR INSURANCE QUOTES UTAH accident attorney orange county car insurance companies online colledges harddrive data recovery services Insurance Companies best mesothelioma lawyers mesotheioma Business finance group mesotheloma Criminal defense lawyer Annuity Settlements Car Insurance Quotes PA Met Auto Custom Christmas cards quotes car Online casino WordPress themes for designers Dedicated Hosting Dedicated Server Hosting Computer science classes online injury attorney baton rouge Online Colleges personal injury solicitor car insurance quotes colorado MESOTHELIOMA LAW FIRM auto accident attorney arizona auto accident attorney Mobile casino CAR INSURANCE QUOTES COLORADO mesothelioma lawyer texas Make money online Australia Hire php developer Social media strategies google affiliate Online motor insurance quotes MOTOR REPLACEMENTS fortis health insurance temporary Car Insurance Quotes Colorado injury lawyers Casino reviews Best social media platforms for business domain yahoo DALLAS MESOTHELIOMA ATTORNEYS Live casino mesothelioma charities Cheap Auto Insurance in VA DUI lawyer Forensics Online Course Injury Lawyers massage school dallas texas Automobile Accident Attorney Hire php developers Donate Cars in MA Webex Costs saskatchewan auto insurance domain name yahoo Futuristic Architecture Hire php programmers Tech school city college in miami donating used cars to charity benchmark lending structured settlement cash out selling structured settlement Dwi lawyer cheap car insurance in virginia Criminal lawyer Seo services Service business software donate old cars to charity Php programmers for hire state of california car insurance Motor Insurance Quotes Donating Used Cars to Charity Motor replacements CHEAP CAR INSURANCE IN VIRGINIA mesothelioma structured settlement company Nunavut culture DONATE YOUR CAR FOR MONEY Psychic for Free ONLINE COLLEDGES Seo company Bankruptcy lawyer emergency response plan ppt DONATE OLD CARS TO CHARITY sell annuity payment Best Criminal Lawyers in Arizona Donate Your Car for Kids Paperport promotional code new york mesothelioma law firm Php programmers Car Insurance Quotes MN mesothelioma information Social media management Christmas cards car accident lawyer san bernardino Mesothelioma Law Firm STRUCTURED ANNUITY SETTLEMENT Auto Mobile Shipping Quote lease management software Donate cars Illinois Mortgage Adviser Social media examiner Seo companies Low credit line credit cards New social media platforms asbestos lawyers CRIMINAL DEFENSE ATTORNEYS FLORIDA Social media platforms for business Custom WordPress theme designer DONATE YOUR CAR FOR KIDS business voip solutions Best Seo company Business management software what is structured settlement Best social media platforms att call conference Donate a Car in Maryland best criminal lawyer in arizona donate your car for money Online Christmas cards Psd to html WEBEX COSTS Photo Christmas cards Car Insurance Quotes WordPress hosting car crash attorneys Psd to WordPress florida car insurance company Cheap domain registration hosting mesothelioma attorney assistance Donate your car for money Html email Social media platforms offshore accident lawyer mesothelioma lawyer virginia Donate Car to Charity California Proud Italian cook criminal defense federal lawyer holland michigan college Dallas Mesothelioma Attorneys forensics online course buyer of structured settlement annuity Motor Replacements Life Insurance Co Lincoln Italian cooking school WordPress theme designers Adobe illustrator classes new mexico mesothelioma lawyer injury lawyers west palm beach MET AUTO mesothelioma trial attorney mesothelioma lawyer california Donating used cars to charity Royalty free images stock Business Voip Solutions motor insurance quotes Learning adobe illustrator Online Stock Trading domains yahoo Social media tools Social media campaigns car insurance in south dakota World Trade Center Footage Donate Car for Tax Credit DONATING A CAR IN MARYLAND DONATE YOUR CAR SACRAMENTO Dayton Freight Lines Virtual Data Rooms structured settlements annuities pharmacist jobs in chicago How to Donate A Car in California ROYALTY FREE IMAGES STOCK Donate Your Car Sacramento Sell Annuity Payment Donate Cars Illinois Asbestos Lawyers purchase structured settlements Structures Annuity Settlement annuity payment Nunavut Culture Hard drive Data Recovery Services Criminal lawyer Miami Car Accident Lawyers car accident lawyers los angeles Cheap Domain Registration Hosting Donating a Car in Maryland virtual data rooms Criminal Defense Attorneys Florida PHD on Counseling Education Car Insurance Quotes Utah Holland Michigan College Online Motor Insurance Quotes Paperport Promotional Code Online Classes cloud identity and access management houston tx auto insurance Massage School Dallas Texas Donate Old Cars to Charity DAYTON FREIGHT LINES HOME PHONE INTERNET BUNDLE Low Credit Line Credit Cards student loan consolidation program REGISTER FREE DOMAINS mesothelioma compensation Donate your Car for Money alcohol rehab center in florida car accident lawyers west palm beach cheap domain registration hosting Home Phone Internet Bundle Home phone internet bundle average mesothelioma settlement mortgage adviser Cheap Car Insurance for Ladies Neuson Royalty Free Images Stock mesotheolima structured settlement annuity companies Car Insurance in South Dakota Donate car for tax credit Email Bulk Service event management security google adsense Cheap Car Insurance in Virginia Register Free Domains Better Conference Calls Massage school Dallas Texas AUTO ACCIDENT ATTORNEY Claim cheaper insurance companies Car Donate Online College Course Auto Accident Attorney Data Recovery Raid SELL ANNUITY PAYMENT la personal injury lawyer hosted predictive dialers Personal Injury Lawyers Asbestos Lung Cancer Dallas mesothelioma attorneys Personal Injury Law Firm Online Criminal Justice Degree Car Insurance Companies truck accident attorney los angeles motorcycle accident attorney chicago canada personals yahoo selling annuity