Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int first, second;
- string input;
- int masivNoseniNomera[10] = {};
- int masivNalichniNomera[10] = {};
- int noseniNomeraCounter = 1;
- int nalichniNomeraCounter = 1;
- string newString;
- int arrayCounter [] = {};
- int whileTimes = 0;
- long sstoi(const char *s) // custom stoi function
- {
- long i;
- i = 0;
- while(*s >= '0' && *s <= '9')
- {
- i = i * 10 + (*s - '0');
- s++;
- }
- return i;
- }
- int counter =0;
- int arrayOutput[10] = {};
- int whileCounter = 0;
- int main()
- {
- for(int i=0; i<10; i++)
- {
- arrayCounter[i] = 0;
- arrayOutput[i] = 0;
- }
- stringstream sstream;
- int k =0;
- cin >> k;
- cin.ignore();
- while(k--)
- {
- // cout << "Loop" << endl;
- if(whileTimes>0)
- {
- cin.ignore();
- }
- getline(cin, input);
- sstream.str(input);
- sstream >> newString;
- int firstNumber = sstoi(newString.c_str());
- // masivNoseniNomera[firstNumber] = {};
- sstream >> newString;
- int secondNumber = sstoi(newString.c_str());
- // masivNalichniNomera[secondNumber] = {};
- sstream.str("");
- sstream.clear(); // izchistva greshki
- getline(cin, input);
- sstream.str(input);
- sstream >> newString;
- masivNoseniNomera[0] = sstoi(newString.c_str());
- while(sstream.eof()!=1)
- {
- sstream >> newString;
- // sstream.clear();
- masivNoseniNomera[noseniNomeraCounter] = sstoi(newString.c_str());
- noseniNomeraCounter++;
- }
- sstream.str("");
- sstream.clear(); // izchistva greshki
- //
- getline(cin, input);
- sstream.str(input);
- sstream >> newString;
- masivNalichniNomera[0] = sstoi(newString.c_str());
- while(sstream.eof()!=1)
- {
- sstream >> newString;
- // sstream.clear();
- masivNalichniNomera[nalichniNomeraCounter] = sstoi(newString.c_str());
- nalichniNomeraCounter++;
- }
- sstream.str("");
- sstream.clear(); // izchistva greshki
- /* cout << "The first number is: " << firstNumber << " and the second number is: " << secondNumber << endl;
- for(int i =0; i<noseniNomeraCounter; i++)
- {
- cout << masivNoseniNomera[i] << endl;
- }
- }*/
- for(int i =0; i<noseniNomeraCounter; i++)
- {
- int segashenNosenNomer = masivNoseniNomera[i];
- for(int j =0; j<nalichniNomeraCounter;j++)
- {
- int segashenNalicherNomer = masivNalichniNomera[j];
- if((segashenNosenNomer<=segashenNalicherNomer) && (segashenNalicherNomer !=0))
- {
- counter++;
- masivNalichniNomera [j] = 0;
- break;
- }
- }
- }
- // cout << "PRINTVAM COUNTER" << counter << endl;
- arrayOutput[whileCounter]= counter;
- whileCounter++;
- for(int i =0; i<=9; i++)
- {
- masivNoseniNomera[i] =0;
- }
- for(int i =0; i<=9; i++)
- {
- masivNalichniNomera[i] =0;
- }
- noseniNomeraCounter = 0;
- nalichniNomeraCounter =0;
- counter = 0;
- }
- for(int i =0; i<whileCounter; i++)
- {
- cout << arrayOutput[i]<< endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement