SlideShare una empresa de Scribd logo
1 de 6
“Año de la Integración Nacional y el Reconocimiento de Nuestra
Diversidad”

UNIVERSIDAD NACIONAL
”SAN LUIS GONZAGA DE ICA”

FACULTAD DE INGENIERIA MECÁNICA Y ELÉCTRICA
ESCUELA PROFESIONAL DE INGENIERIÍA ELECTRONICA

TEMA
VECTOR O ARRAY
CURSO

: LENGUAJE DE PROGRAMACION 2

ALUMNA

:HUAYTA

DOCENTE

: MUNIVE WILMER

CICLO

:IV “1”

BERROCAL CAROL NÉLIDA

ICA - PERÚ
2013
VECTORES O ARRAY

VECTORES O ARRAY
Un vector, también llamado array(arreglo) unidimensional, es una estructura de datos que
permite agrupar elementos del mismo tipo y almacenarlos en un solo bloque de memoria
juntos, uno despues de otro. A este grupo de elementos se les identifica por un mismo nombre
y la posición en la que se encuentran. La primera posición del array es la posición 0
Podríamos agrupar en un array una serie de elementos de tipo enteros, flotantes, caracteres,
objetos, etc.
EJEMPLO DE ORDENAMIENTO
#include
#include
#include
#include
int vector[100];
void ordenar(int *n,shortintcant)
{
short r,ayu,x;
if (cant==1) cant=0;
do
{
r=0;
for(x=0;x<cant;x++) if(n[x]>n[x+1])
{
ayu=n[x];
n[x]=n[x+1];
n[x+1]=ayu; r++;
}
}
while(r!=0);
system(“PAUSE>null”);
system(“cls”);
}
main()
{
int i=0;
printf(“nntt>>>>>> ORDENADOR DE ELEMENTOS RESISTIVOS <<<<<<nnn”);
printf(“Ingresar los 10 valores resistivosnnn”); do { printf(“::> “);
scanf(“%i”,&vector[i]) ;i++;

HUAYTA BERROCAL C.

2
VECTORES O ARRAY

}
while(i<10);
printf(“nn*** Precionar cualquier tecla para realizar el ordenamiento de resistencias ***”);
ordenar(vector,10);
printf(“n***** ORDENADO DE MENOR A MAYOR Y ELIMINANDO A LA MAYOR
RESISTENCIAS *****n”);
for(short i=1;i<10;i++)
printf(“nn * %i ohm”,vector[i]);
printf(“nnntt ****** HUAYTA BERROCAL, CAROL ******nn”);
getch();
}

HUAYTA BERROCAL C.

3
VECTORES O ARRAY

EJEMPLO DE BUSQUEDA
#include<iostream>
#include<iostream>
#include<conio.h>
#include<math.h>
#define N 4
usingnamespacestd;
intmain()
{
int I;
doubleVmax;
doubleVmin;
intnumeros[N];
int i;
intRmaximo,Rminimo;
// INICIALIZO
Rminimo=1000;
Rmaximo=0;
cout<<”tttINGRESE 4 VALORES RESISTIVOSnn”;
// LECTURA DE LOS ELEMENTOS VECTOR
for(i=0;i<N;i++)
{
cout<<”Ingrese el numero “<<i+1<<” = “;
cin>>(numeros[i]);
}
// PROCESO calcula el MAXIMO Y EL MINIMO
for(i=0;i<N;i++)
{
if(numeros[i]<Rminimo)
Rminimo=numeros[i];

HUAYTA BERROCAL C.

4
VECTORES O ARRAY

if(numeros[i]>Rmaximo)
Rmaximo=numeros[i];
}
cout<<”nnn”;
cout<<”EL MAXIMO DE LAS RESISTENCIAS ES : “<<Rmaximo<<” Ohm ,”;
cout<<”nn”;
cout<<”EL MINIMO DE LAS RESISTENCIAS ES : “<<Rminimo<<” Ohm ,”;
cout<<”nn”;
//calculo de voltaje maximo
cout<<”nn”;
cout<<”ingresar corriente= “;cin>>I;
for(Vmax=0;Vmax<I;Vmax++)
{
Vmax=Rmaximo*I;
}
cout<<”n”;
cout<<”voltaje maximo es = “<<Vmax<<” Volt ,”;
cout<< ” FIN!n”;
//calculo de voltaje minimo
cout<<”nn”;
cout<<”ingresar corriente = “;cin>>I;
for(Vmin=0;Vmin<I;Vmin++)
{
Vmin=Rminimo*I;
}
cout<<”n”;
cout<<”voltaje minimo es = “<<Vmin<<” Volt ,”;
cout<< ” FIN!n”;
}

HUAYTA BERROCAL C.

5
VECTORES O ARRAY

HUAYTA BERROCAL C.

6

Más contenido relacionado

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Vectores o array

  • 1. “Año de la Integración Nacional y el Reconocimiento de Nuestra Diversidad” UNIVERSIDAD NACIONAL ”SAN LUIS GONZAGA DE ICA” FACULTAD DE INGENIERIA MECÁNICA Y ELÉCTRICA ESCUELA PROFESIONAL DE INGENIERIÍA ELECTRONICA TEMA VECTOR O ARRAY CURSO : LENGUAJE DE PROGRAMACION 2 ALUMNA :HUAYTA DOCENTE : MUNIVE WILMER CICLO :IV “1” BERROCAL CAROL NÉLIDA ICA - PERÚ 2013
  • 2. VECTORES O ARRAY VECTORES O ARRAY Un vector, también llamado array(arreglo) unidimensional, es una estructura de datos que permite agrupar elementos del mismo tipo y almacenarlos en un solo bloque de memoria juntos, uno despues de otro. A este grupo de elementos se les identifica por un mismo nombre y la posición en la que se encuentran. La primera posición del array es la posición 0 Podríamos agrupar en un array una serie de elementos de tipo enteros, flotantes, caracteres, objetos, etc. EJEMPLO DE ORDENAMIENTO #include #include #include #include int vector[100]; void ordenar(int *n,shortintcant) { short r,ayu,x; if (cant==1) cant=0; do { r=0; for(x=0;x<cant;x++) if(n[x]>n[x+1]) { ayu=n[x]; n[x]=n[x+1]; n[x+1]=ayu; r++; } } while(r!=0); system(“PAUSE>null”); system(“cls”); } main() { int i=0; printf(“nntt>>>>>> ORDENADOR DE ELEMENTOS RESISTIVOS <<<<<<nnn”); printf(“Ingresar los 10 valores resistivosnnn”); do { printf(“::> “); scanf(“%i”,&vector[i]) ;i++; HUAYTA BERROCAL C. 2
  • 3. VECTORES O ARRAY } while(i<10); printf(“nn*** Precionar cualquier tecla para realizar el ordenamiento de resistencias ***”); ordenar(vector,10); printf(“n***** ORDENADO DE MENOR A MAYOR Y ELIMINANDO A LA MAYOR RESISTENCIAS *****n”); for(short i=1;i<10;i++) printf(“nn * %i ohm”,vector[i]); printf(“nnntt ****** HUAYTA BERROCAL, CAROL ******nn”); getch(); } HUAYTA BERROCAL C. 3
  • 4. VECTORES O ARRAY EJEMPLO DE BUSQUEDA #include<iostream> #include<iostream> #include<conio.h> #include<math.h> #define N 4 usingnamespacestd; intmain() { int I; doubleVmax; doubleVmin; intnumeros[N]; int i; intRmaximo,Rminimo; // INICIALIZO Rminimo=1000; Rmaximo=0; cout<<”tttINGRESE 4 VALORES RESISTIVOSnn”; // LECTURA DE LOS ELEMENTOS VECTOR for(i=0;i<N;i++) { cout<<”Ingrese el numero “<<i+1<<” = “; cin>>(numeros[i]); } // PROCESO calcula el MAXIMO Y EL MINIMO for(i=0;i<N;i++) { if(numeros[i]<Rminimo) Rminimo=numeros[i]; HUAYTA BERROCAL C. 4
  • 5. VECTORES O ARRAY if(numeros[i]>Rmaximo) Rmaximo=numeros[i]; } cout<<”nnn”; cout<<”EL MAXIMO DE LAS RESISTENCIAS ES : “<<Rmaximo<<” Ohm ,”; cout<<”nn”; cout<<”EL MINIMO DE LAS RESISTENCIAS ES : “<<Rminimo<<” Ohm ,”; cout<<”nn”; //calculo de voltaje maximo cout<<”nn”; cout<<”ingresar corriente= “;cin>>I; for(Vmax=0;Vmax<I;Vmax++) { Vmax=Rmaximo*I; } cout<<”n”; cout<<”voltaje maximo es = “<<Vmax<<” Volt ,”; cout<< ” FIN!n”; //calculo de voltaje minimo cout<<”nn”; cout<<”ingresar corriente = “;cin>>I; for(Vmin=0;Vmin<I;Vmin++) { Vmin=Rminimo*I; } cout<<”n”; cout<<”voltaje minimo es = “<<Vmin<<” Volt ,”; cout<< ” FIN!n”; } HUAYTA BERROCAL C. 5
  • 6. VECTORES O ARRAY HUAYTA BERROCAL C. 6