Facebook
From Chunky Macaque, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 272
  1. // 1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<Windows.h>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9. int tab[] = {0,0,0,0,0,0};
  10. int Mtab[] ={1,2,3,4,4,5};
  11. int Max_Value = 7;
  12.  
  13. int _used;
  14. int changes;
  15. void check()
  16. {
  17.         for(int _nr = 0; _nr < Max_Value; _nr++)
  18.         {
  19.                 _used = tab[_nr];
  20.                 cout << "N_set"<<endl;
  21.                         for (int i = 0; i < Max_Value; i++)
  22.                         {
  23.                                 if (_nr != i)
  24.                                 {
  25.                                         if (_used == tab[i])
  26.                                         {
  27.                                                 tab[i] = rand() % 7 + 1;
  28.                                                 cout << tab[i] << endl;
  29.                                         }
  30.                                 }
  31.                         }
  32.         }
  33.         cout<< "check succed" << endl;
  34. }
  35. void generate()
  36. {
  37.         for (int _nr = 0; _nr < Max_Value; _nr++)
  38.         {
  39.                 tab[_nr] = Mtab[_nr];
  40.                 cout << tab[_nr] << "  ";
  41.         }
  42.         cout << endl;
  43.         cout << "generate succed" << endl;
  44.         check();
  45. }
  46. void Sresults()
  47. {
  48.         for (int _nr = 0; _nr < Max_Value; _nr++)
  49.         {
  50.                 cout << Mtab[_nr] << "  ";
  51.         }
  52.         cout << endl;
  53.         for (int _nr = 0; _nr < Max_Value; _nr++)
  54.         {
  55.                 cout << tab[_nr] << "  ";
  56.         }
  57.         cout << endl;
  58.         cout <<"$#-"<< changes;
  59. }
  60.  
  61. int main()
  62. {
  63.         generate();
  64.         Sresults();
  65.         system("pause");
  66.     return 0;
  67. }