Advertisement
NuquernaNarsil

Maturalne OKE 2013 grudzień

Dec 12th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. main()
  9. {
  10.  ifstream wczyt;
  11.  ofstream zap;
  12.  
  13.  int i=0, tab1[10],tab2[10], licz=0, x=0, temp=0;
  14.  string nr1, nr2;
  15.  
  16.  wczyt.open("dane_anagramy.txt");
  17.  if(wczyt.is_open())
  18.  {
  19.   while(wczyt)
  20.   {
  21.    wczyt >> nr1;
  22.    wczyt >> nr2;
  23.    for(int i = 0; i<10; i++)
  24.    {
  25.    tab1[i]=0;
  26.            for(int j=0; j<8 ; j++)
  27.            {
  28.                    if(int(nr1[j])-48 == i)
  29.                    tab1[i]++;
  30.            }
  31.    }
  32.    
  33.    for(int i = 0; i<10; i++)
  34.    {
  35.    tab2[i]=0;
  36.            for(int j=0; j<8 ; j++)
  37.            {
  38.                    if(int(nr2[j])-48 == i)
  39.                    tab2[i]++;
  40.            }
  41.    }
  42.    
  43.    temp=0;
  44.    for(int i=0; i<10; i++)
  45.    {
  46.     if(tab1[i]!=tab2[i])
  47.     {
  48.      temp=0;                  
  49.      break;
  50.     }
  51.     else
  52.      temp++;
  53.    }
  54.    if (temp>=1)
  55.       licz++;
  56.    
  57.    //x++;
  58.       //  if(x==1)
  59.       //  break;                  
  60.                        
  61.   }
  62.   cout <<"Ilosc liczb: "<< licz;
  63.  }
  64.  wczyt.close();
  65.  getch();
  66.  return 0;      
  67.      
  68.      
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement