Advertisement
zaidhuda

Multiplication *something* style

Apr 7th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include "iostream"
  2. int main(int argc, char const *argv[]){
  3.   int total=0;
  4.  
  5.   std::string str1, str2;
  6.   std::cin >> str1 >> str2;
  7.   for (int i = 0; i < str1.length(); ++i)
  8.     for (int j = 0; j < str2.length(); ++j){
  9.       // cout << str1[i] << " " << str2[j] << " " << (str1[i]-48)*(str2[j]-48) << "\n";
  10.       total += (str1[i]-48)*(str2[j]-48);
  11.     }
  12.  
  13.   std::cout << total << "\n";
  14.   return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement