Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // wektor.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <cstdio>
- #include <ctime>
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int main ()
- {
- int W[10],W2[10], index=0;
- srand(time(NULL));
- cout<<"Program sprawdzajacy redundancje elementow w wektorze "<<endl<<"oraz podajacy pozycje powtarzajaych sie elementow: "<<endl<<endl;
- for(int i=0;i<10;i++)
- {
- W[i]=rand()%10;
- cout<<W[i]<<"\t";
- }
- for(int i=0;i<10;i++){
- W2[i]=W[i];
- }
- for(int i=0;i<10;i++){
- for(int j=i+1;j<10;j++){
- if(W[i]==W2[j]){
- cout<<endl<<"Powtarza siÄ™ element na pozycji "<<j+1<<" o wartosci"<<W[i]<<endl<<endl;
- W2[j]=-1;
- }
- }
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement