fork download
  1. #include <iostream>
  2. bool checkChar(std::string one,std::string two)
  3. {
  4. if(one.length()>two.length())return false;
  5. if(one.length()<two.length())return true;
  6. if(one==two)return false;
  7. for(unsigned int i=0;i<one.length();++i)
  8. if(one[i]>two[i])return false;
  9. return true;
  10. }
  11. int main()
  12. {
  13. int amount,number,*result;
  14. std::string*tab,*smallThan;
  15. std::cin>>amount;
  16. tab=new std::string [amount];
  17. for(int i=0;i<amount;++i)std::cin>>tab[i];
  18. std::cout<<std::endl;
  19. std::cin>>number;
  20. smallThan=new std::string [number];
  21. result=new int [number];
  22. for(int i=0;i<number;++i)std::cin>>smallThan[i];
  23. for(int Count=0,j=0;j<number;++j,Count=0){for(int i=0;i<amount;++i)if(checkChar(tab[i],smallThan[j]))++Count;result[j]=Count;}
  24. for(int i=0;i<number;++i)std::cout<<result[i]<<std::endl;
  25. delete []tab;
  26. delete []smallThan;
  27. delete []result;
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 16064KB
stdin
10
5
4
2
3
1
1
10
20
15
100

3
7
1
18
stdout
6
0
8