Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. // wektor.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <cstdio>
  6. #include <ctime>
  7. #include <iostream>
  8. #include <cstdlib>
  9. #include <time.h>
  10. using namespace std;
  11.  
  12. int main ()
  13. {
  14.     int W[10],W2[10], index=0;
  15.     srand(time(NULL));
  16.    
  17.     cout<<"Program sprawdzajacy redundancje elementow w wektorze "<<endl<<"oraz podajacy pozycje powtarzajaych sie elementow: "<<endl<<endl;
  18.    
  19.     for(int i=0;i<10;i++)
  20.     {
  21.        
  22.         W[i]=rand()%10;
  23.        
  24.         cout<<W[i]<<"\t";
  25.        
  26.     }
  27.  
  28.     for(int i=0;i<10;i++){
  29.         W2[i]=W[i];
  30.     }
  31.     for(int i=0;i<10;i++){
  32.         for(int j=i+1;j<10;j++){
  33.             if(W[i]==W2[j]){
  34.             cout<<endl<<"Powtarza siÄ™ element na pozycji "<<j+1<<" o wartosci"<<W[i]<<endl<<endl;
  35.             W2[j]=-1;
  36.             }
  37.         }
  38.     }
  39.  
  40.  
  41.     system("PAUSE");
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement