Skip to content

Instantly share code, notes, and snippets.

@IuryAlves
Last active December 27, 2015 19:39
Show Gist options
  • Select an option

  • Save IuryAlves/7378709 to your computer and use it in GitHub Desktop.

Select an option

Save IuryAlves/7378709 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <map>
#include <utility>
using namespace std;
/* dado usa sequencia de caracteres numericos imprime quantos leds serão preciso para mostrar os caracteres
é utilizado a entrada e saída padrão
*/
int main(){
map<char,int> leds;
int n,i,j,result = 0;
string valor;
leds.insert(pair<char, int>('0',6));
leds.insert(pair<char, int>('1',2));
leds.insert(pair<char, int>('2',5));
leds.insert(pair<char, int>('3',5));
leds.insert(pair<char, int>('4',4));
leds.insert(pair<char, int>('5',5));
leds.insert(pair<char, int>('6',6));
leds.insert(pair<char, int>('7',4));
leds.insert(pair<char, int>('8',7));
leds.insert(pair<char, int>('9',6));
map<char, int>::iterator iter;
while(cin >> n){
for(j = 0; j <= n; j++){
getline(cin,valor);
for(i = 0; i < valor.size(); i++){
iter = leds.find(valor[i]);
result += iter->second;
}
cout << result << '\n';
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment