Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <string>
- #include <unordered_map>
- using namespace std;
- int readFile();
- int readFile2();
- int kiekVaiku = 0;
- int kiekSkaiciu = 0;
- int temp = 0;
- int kelintasVaikas = 0;
- int reikiaSk = 0;
- int main() {
- readFile();
- unordered_map<string, int[]> hash;
- int *tempSkaiciai = new int[kiekSkaiciu];
- readFile2();
- hash["" + kelintasVaikas] = tempSkaiciai;
- reikiaSk+=1;
- readFile2();
- hash["" + kelintasVaikas] = tempSkaiciai;
- reikiaSk+=1;
- readFile2();
- hash["" + kelintasVaikas] = tempSkaiciai;
- reikiaSk+=1;
- for(int i = 0 ; i < kiekVaiku ; i++){
- boolean vienas = false;
- boolean du = false;
- boolean trys = false;
- boolean keturi = false;
- boolean penki = false;
- boolean sesi = false;
- boolean septyni = false;
- boolean astuoni = false;
- boolean devyni = false;
- boolean desimt = false;
- int *laikinasMas = hash.at("" + i);
- for(int i = 0 ; i < kiekSkaiciu ; i++){
- if(laikinasMas[i] == 1){
- vienas = true;
- } else if(laikinasMas[i] == 2){
- du = true;
- } else if(laikinasMas[i] == 3){
- trys = true;
- } else if(laikinasMas[i] == 4){
- keturi = true;
- } else if(laikinasMas[i] == 5){
- penki = true;
- } else if(laikinasMas[i] == 6){
- sesi = true;
- } else if(laikinasMas[i] == 7){
- septyni = true;
- } else if(laikinasMas[i] == 8){
- astuoni = true;
- } else if(laikinasMas[i] == 9){
- devyni = true;
- } else if(laikinasMas[i] == 10){
- desimt = true;
- }
- }
- cout << i + " vaikas = ";
- if(vienas){
- cout << "1";
- }else{
- cout << "0";
- }
- if(du){
- cout << "2";
- }else{
- cout << "0";
- }
- if(trys){
- cout << "3";
- }else{
- cout << "0";
- }
- if(keturi){
- cout << "4";
- }else{
- cout << "0";
- }
- if(penki){
- cout << "5";
- }else{
- cout << "0";
- }
- if(sesi){
- cout << "6";
- }else{
- cout << "0";
- }
- if(septyni){
- cout << "7";
- }else{
- cout << "0";
- }
- if(astuoni){
- cout << "8";
- }else{
- cout << "0";
- }
- if(devyni){
- cout << "9";
- }else{
- cout << "0";
- }
- if(desimt){
- cout << "10";
- }else{
- cout << "0";
- }
- cout << endl;
- }
- return 0;
- }
- int readFile(){
- string text;
- ifstream inFile;
- inFile.open("C:\\Users\\Mokinys01\\Desktop\\Duomenys.txt");
- if(inFile.is_open()){
- while(getline((inFile,text))){
- if(temp == 0){
- std::istringstream iss (text);
- iss >> kiekVaiku;
- temp++;
- }else if(temp == 1){
- std::istringstream iss (text);
- iss >> kiekSkaiciu;
- temp++;
- }
- }
- }
- temp++;
- inFile.close();
- }
- int readFile2(){
- string text;
- ifstream inFile;
- inFile.open("C:\\Users\\menu8\\Desktop\\duomenys.txt");
- int o = 0;
- if(inFile.is_open()){
- while(getline((inFile,text))){
- if(temp == 2 && reikiaSK == 0){
- for(int i = 0 ; i < kiekSkaiciu ; i++){
- std::istringstream iss (text);
- iss >> tempSkaiciai(o);
- o++;
- }
- }else if(temp == 3 && reikiaSk == 1){
- for(int i = 0 ; i < kiekSkaiciu ; i++){
- std::istringstream iss (text);
- iss >> tempSkaiciai(o);
- o++;
- }
- }else if(temp == 4 && reikiaSk == 2){
- for(int i = 0 ; i < kiekSkaiciu ; i++){
- std::istringstream iss (text);
- iss >> tempSkaiciai(o);
- o++;
- }
- }
- }
- }
- temp++;
- inFile.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement