mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-02-27 11:58:39 +08:00
routine
This commit is contained in:
23
26/01/comp/18q1.cpp
Normal file
23
26/01/comp/18q1.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <string>
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
int vowelConsonantScore(std::string s) {
|
||||
int v =0,c=0;
|
||||
std::string col = "aeiou";
|
||||
for (auto i : s) {
|
||||
if (i > 122 || i < 97) {
|
||||
continue;
|
||||
}
|
||||
if (col.find(i) != std::string::npos) {
|
||||
v++;
|
||||
}else {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
if (c==0) {
|
||||
return 0;
|
||||
}
|
||||
return v/c;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user