hay points

#include <iostream>
#include <string>
#include <cstdio>
#include <vector>

using namespace std;

int main(){
int m;
int n;
int a = 0;
cin>>m;
cin>>n;
string s[m];
string str[100000];
string tes;
char c;
long long d[m];
long long salary = 0;
for(int i = 0 ; i<m ; i++){
cin>>s[i];
cin>>d[i];
}
while(cin>>tes){

str[a] = tes;
a++;
do{
cin>>str[a];
a++;
} while(str[a-1]!=".");


for(int j = 0 ; j<a ; j++){
for(int k = 0 ; k<m ; k++){
if (s[k] == str[j]) salary = salary + d[k];
}
}
cout<<salary<<endl;

a = 0;
salary = 0;
}

return 0;

}
So, what problem do you have?
The code, indented and formatted.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
  int m;
  int n;
  int a = 0;
  cin >> m;
  cin >> n;
  string s[m];
  string str[100000];
  string tes;
  char c;
  long long d[m];
  long long salary = 0;

  for (int i = 0; i < m; i++) {
    cin >> s[i];
    cin >> d[i];
  }

  while (cin >> tes) {
    str[a] = tes;
    a++;
    do {
      cin >> str[a];
      a++;
    } while (str[a - 1] != ".");

    for (int j = 0; j < a; j++) {
      for (int k = 0; k < m; k++) {
        if (s[k] == str[j])
          salary = salary + d[k];
      }
    }
    cout << salary << endl;

    a = 0;
    salary = 0;
  }

  return 0;
}
nicozhou, please be aware that this site helps C++ programmers from around the world with whatever problems they are having. So until you tell us, we have no idea what problem you're trying to solve or what's wrong with your code. If this is a homework assignment or a problem from some programming site, please post the text of the assignment or a link to the problem.
while its unclear what he is trying to do, this can't be right.

while (cin >> tes) {
str[a] = tes;
a++; ///this looks like it eventually goes awol. it should probably set a=0 inside the loop.
do {
cin >> str[a];
a++;
} while (str[a - 1] != ".");
Topic archived. No new replies allowed.