Monday, May 1, 2017

URI Solution 1218 Getline Three - Shoes - Solution in C++ | Ad Hoc

URI Solution 1218 Getline Three - Shoes- Solution in C++ | Ad Hoc


URI Online Judge Solution Getline Three - Shoes | Ad Hoc
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1218

Problem Name: URI Problem Getline Three - Shoes
Problem Number : URI - 1218
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1218 Code in CPP:


#include <cstdio>
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int main()
{
 int n, size, number, count = 1;
    string s, num, tipo;
    size_t found;

    bool p = false;
    while(scanf("%i", &n) != EOF)
    {
     if(p) cout << endl;
     p = true;
     cin.ignore();
  getline(cin, s);
  int masc[45] = {0}; int femi[45] = {0};
  size = s.size();

  for (int i = 0; i < size; i += 5)
  {
   found = s.find(" ");
   num = s.substr(0, found);
   s = s.substr(found + 1);

   found = s.find(" ");
   tipo = s.substr(0, found);
   s = s.substr(found + 1);

   number = atoi(num.c_str());
   if(tipo == "M"){
    masc[number]++;
   }else{
    femi[number]++;
   }
  }

     cout << "Caso " << count << ":" << endl;
       cout << "Pares Iguais: " << (masc[n] + femi[n]) << endl;
       cout << "F: " << femi[n] << endl << "M: " << masc[n];
       count++;
      
       cout << endl;
    }

   return 0;
}

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.