Bun venit Guest | RSS
Bine ati venit la 9C acasa
Meniul Site-ului
Horoscop
Exprima-ti opinia
Ce parere aveti despre site?
1. Foarte buna
2. Foarte proasta
3. Buna
4. Normal
5. Proasta
[ Vezi rezutat ยท Arhiva ]
Raspunsuri: 42
Mini chat

Info


Main » 2010 » Mai » 18 » citire/afisare/diferenta.produs cartezian/ordonare vector cu fisiere
citire/afisare/diferenta.produs cartezian/ordonare vector cu fisiere
14:08

//se citesc 2 vectori de dimensiuni diferite n si mcu elemente de tip intreg
//reuniunea
//2.intersectia
//3.diferenta
//4produsul caretezian
//5.ordonare crescatoare

#include<iostream.h>
#include<iomanip.h>

int a[20],b[20],m,n,c[50],i,j,d[20],e[20],aux,k,x;
#include"citire.cpp"
#include"reuniune.cpp"
void main()
{
cout<<"n="; cin>>n;
cout<<"m=";cin>>m;
citire(a,n);
afisare(a,n);
cout<<endl;
citire(b,m);
afisare(b,m);cout<<endl;
reuniune(a,b,n,m);
cout<<endl<<"Toate elementele"<<endl;
afisare(c,k);
cout<<endl<<"reuniunea numerelor"<<endl;
eliminare(c,k);
cout<<endl<<"intersectia numerelor"<<endl;
intersectie(a,b);
cout<<endl<<"produsul cartezian este"<<endl;
cartezian(a,b);
cout<<endl<<"ordonare crescatoare a primului vector"<<endl;
ordonare(a,n);
afisare(a,n);
cout<<endl<<"ordonare crescatoare a primului vector"<<endl;
ordonare(b,m);
afisare(b,m);
cout<<endl<<"diferenta numerelor este"<<endl;
diferenta(a,n,m,b);}


"reuniune.cpp"
void reuniune(int a[20],int b[20], int n,int m)
{k=0;
for(i=1;i<=n;i++)
{k++;
c[k]=a[i];}
for(j=1;j<=m;j++)
{k++;
c[k]=b[j];}}
void eliminare(int a[10],int n)
{int x;
for(i=1;i<=n;i++)
{x=0;
for(j=1;j<i;j++)
if(a[i]==a[j])
x=1;
if(x==0) cout<<a[i]<<" ";}}
int intersectie(int a[10],int b[10])
{for(i=1;i<=n;i++)
{for(j=1;j<=m;j++)
if(a[i]==b[j])
cout<<a[i]<<" ";}}
int cartezian(int a[10],int b[10])
{for(i=1;i<=n;i++)
{for(j=1;j<=m;j++)
cout<<"("<<a[i]<<","<<b[j]<<")"<<" ";
}}
void ordonare(int a[10],int n)
{for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
if(a[i]>a[j])
{aux=a[i];
a[i]=a[j];
a[j]=aux;}}
int diferenta(int a[10],int n,int m,int b[10])
{i=1;
while(i<=n)
{x=0;
for(j=1;j<=m;j++)
if(a[i]==b[j])
x++;
if(x==0)
cout<<a[i]<<" ";
i++;}}

"citire.cpp"

void citire(int a[20],int n)
{for(i=1;i<=n;i++)
{cout<<"a["<<i<<"]=";
cin>>a[i];
}}

void afisare(int a[20],int n)
{for(i=1;i<=n;i++)
cout<<a[i]<<" ";}
 
Views: 1324 | Added by: Iulian
Only registered users can add comments.
[ Registration | Login ]
Logheaza-te
Calendar
«  Mai 2010  »
DuLuMaMiJoViSa
      1
2345678
9101112131415
16171819202122
23242526272829
3031
Meteo
Curs Valutar
Curs Valutar BNR
Cautare
Link-uri
Statistica
Director web gratuit - Afisare Thumbnail, Transfer Google PageRank, Meta keywords si meta description personalizate pentru fiecare link Site clasei 9C Colegiul National Mihai Eminescu, Muzica Stiri Sport, Filme Top66 Statistici
Total online: 1
Guests: 1
Users: 0