本文整理汇总了C++中vs类的典型用法代码示例。如果您正苦于以下问题:C++ vs类的具体用法?C++ vs怎么用?C++ vs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: toString
//debugging purpose
void toString(){
cerr << "Call name: " << call_fun_name << " | Functions: ";
for(vs::iterator i = function_uses.begin(); i != function_uses.end(); i++){
cerr << *i << " ";
}
cerr << "| Pairs Size " << pairs.size() << endl;
}
开发者ID:killmyrene,项目名称:pipair,代码行数:8,代码来源:pipair.cpp
示例2: containsElem
//----------------------------------------------------------------------------
// Returns true if a given vector<string> contains given string
//----------------------------------------------------------------------------
bool containsElem(vs list, string value) {
for (vs::iterator it = list.begin(); it != list.end(); it++) {
if (*it == value) {
return true;
}
}
return false;
}
开发者ID:killmyrene,项目名称:pipair,代码行数:11,代码来源:pipair.cpp
示例3: parse_obstacles
vvb parse_obstacles(const vs &initial_map) {
vvb obstacles(initial_map.size()+2, vector<bool>(initial_map[0].size()+2, true));
for (int i = 0; i < initial_map.size(); i++) {
for (int j = 0; j < initial_map[i].size(); j++) {
obstacles[i+1][j+1] = (initial_map[i][j] == '*');
}
}
return obstacles;
}
开发者ID:toshihoge,项目名称:ACM-ICPC-Practice,代码行数:9,代码来源:e.cpp
示例4: BuildPath
void BuildPath(map<string, vs> &traces, vvs &pathes, vs &path, string word, string start){
if(word == start){
path.push_back(word);
vs tmp = path;
reverse(tmp.begin(), tmp.end());
pathes.push_back(tmp);
path.pop_back();
return;
}
path.push_back(word);
vs tmp = traces[word];
for(int i = 0; i < tmp.size(); ++i)
BuildPath(traces, pathes, path, tmp[i], start);
path.pop_back();
}
开发者ID:PengyanQin,项目名称:cracking-the-coding-interview,代码行数:15,代码来源:18_10_2.cpp
示例5: print
void print(vs v){
int n=v.size();
for(int i=0;i<n; i++){
cout<<v[i]<<endl;
}
cout<<n;
}
开发者ID:poojagarg,项目名称:Coding,代码行数:7,代码来源:n_k_string.cpp
示例6: main
int main(void) {
std::ios_base::sync_with_stdio (false);
size_t n;
cin >> n >> ws;
vvs graph(n, vs());
dfs_num.resize(n, 0);
parent.resize(n, -1);
finished = false;
a = b = c = -1;
string line;
for (size_t line_cnt = 0; line_cnt < n; line_cnt++) {
getline(cin, line);
for (size_t char_cnt = 0; char_cnt < n; char_cnt++) {
if (line.at(char_cnt) == '1')
graph[line_cnt].push_back(char_cnt);
}
}
for (size_t counter = 0; counter < n; counter++)
if (!dfs_num[counter])
dfs(graph, counter);
if (a >= 0)
cout << a+1 << " " << b+1 << " " << c+1 << endl;
else
cout << -1 << endl;
return 0;
}
开发者ID:bhrzslm,项目名称:codeforces,代码行数:29,代码来源:117C.cpp
示例7: worker
void worker(vs &ret, int level, int pos, string s) {
if(level == 3) {
if(s.size() - pos > 3) return;
else {
string t = s.substr(pos, 3);
if(t[0] == '0' && t.size() != 1) return;
if(stoi(t) <= 255) {
ret.push_back(s);
}
}
return;
}
if(s[pos] == '0') {
string temp = s;
if(pos + 1 >= s.size()) return;
temp.insert(pos + 1, 1, '.');
worker(ret, level + 1, pos + 2, temp);
return;
}
for(int i = pos; i < pos + 3; ++i) {
if(i == pos + 2) {
if(stoi(s.substr(pos, 3)) > 255) {
continue;
}
}
string temp = s;
if(i + 1 >= s.size()) return;
temp.insert(i + 1, 1, '.');
worker(ret, level + 1, i + 2, temp);
}
}
开发者ID:seuzl,项目名称:myleetcode,代码行数:31,代码来源:restoreIPAddresses.cpp
示例8: solve
void solve(vs names,vs towns)
{
int n=names.size();
vs res(n);
map<string,int> f;
rep(i,n){
res[i]=shorten(names[i],towns[i]);
f[res[i]]++;
}
开发者ID:lyoz,项目名称:contest,代码行数:9,代码来源:B.cpp
示例9: format_data
//SBSI has members h, wc, bsa and vtc.
vs* format_data(double data[][5])
{
static vs output;
for(int i = 0;
data[i][0] != 0
|| data[i][1] != 0
|| data[i][2] != 0
|| data[i][3] != 0
|| data[i][4] != 0;
i++){
string* tmp = new SBSI;
tmp->h = data[i][0];
tmp->wc = data[i][1];
tmp->bsa = data[i][2];
tmp->vtc = data[i][3];
tmp->expected = data[i][4];
output.push_back(tmp);
//cout << "Pushed back " << output[i]->h << endl;
}
return &output;
/* char* p1 = data;
char* p2 = p1;
int n = 0;
int counter = 0, length = 0;
while ( p1[0] != '\0') {
SBSI temp;
while ( p1[0] != ',') {
while(!isalpha(p1[0]))
++p1;
p2 = p1+1;
while(*p2 != '\0') {
if(*p2 == '\t')
length++;
break; //Element delimiter.
}
}
}
*/
}
开发者ID:chadenr,项目名称:lab8,代码行数:45,代码来源:lab8.cpp
示例10: fill
string fill(vs ss)
{
int p=ss.size();
string res;
for(int i=0;i/p<ss[i%p].size();i++){
char c=ss[i%p][i/p];
res+=c=='.'?'0':c;
}
return res;
}
开发者ID:lyoz,项目名称:contest,代码行数:10,代码来源:B.cpp
示例11: find_king
pii find_king(const vs &initial_map) {
for (int i = 0; i < initial_map.size(); i++) {
for (int j = 0; j < initial_map[i].size(); j++) {
if (initial_map[i][j] == 'X') {
return make_pair(i+1, j+1);
}
}
}
// never reaches
}
开发者ID:toshihoge,项目名称:ACM-ICPC-Practice,代码行数:10,代码来源:e.cpp
示例12: solve_naive
string solve_naive(vs ss)
{
int k=ss.size(),n=ss[0].size();
rep(i,k){
string s=ss[0]; sort(all(s));
string t=ss[i]; sort(all(t));
if(s!=t)
return "-1";
}
开发者ID:lyoz,项目名称:contest,代码行数:10,代码来源:E.cpp
示例13: returnIndexOfVector
/*
* Returns an integer which is the index
* of a string in a vector of strings
*/
int returnIndexOfVector(vs &stringVector, string value)
{
int iii;
for (iii = 0; iii < stringVector.size(); iii++) {
if (stringVector[iii] == value) {
return iii;
}
}
return -1;
}
开发者ID:novaintel,项目名称:csci4125,代码行数:14,代码来源:functions.cpp
示例14: newMemberTwo
string newMemberTwo(vs existingNames, string newName)
{
set<string> names(existingNames.begin(), existingNames.end());
if(names.count(newName) == 0 )
return newName;
char testName[1024];
int currentInt = 1;
while(1)
{
sprintf(testName, "%s%d", newName.c_str(), currentInt);
if(names.count(testName) == 0)
return testName;
else
currentInt++;
}
}
开发者ID:rusty34,项目名称:TopCoder,代码行数:21,代码来源:UserName.cpp
示例15: work
void work(map<vi, int> & ans, vs & s)
{
int n = s.size(), m = s[0].size();
rep(x, t[m])
{
vi key(n);
rep(i, n) rep(j, m)
key[i] += x / t[j] % 10 + '0' == s[i][j];
auto p = ans.find(key);
if(p == ans.end()) ans[key] = x;
else p->second = -1;
}
开发者ID:JustinLovesCompsci,项目名称:competitions,代码行数:12,代码来源:EllysBulls.cpp
示例16: printCase
void printCase(vs V, vvs A, vd f){
printf("Case Details:\n");
printf("--------------\n");
printf("Number Of Variables n: %d\n\n", V.size());
printf("Rules:\n");
printf("-------\n");
for(int i=0; i<A.size(); i++){
for(int j=0; j<A[i].size(); j++){
printf("%s ", A[i][j].c_str());
}
printf(":: %.3lf\n", f[i]);
}
}
开发者ID:ahmadsoliman,项目名称:BachelorProject,代码行数:13,代码来源:Approximation1.cpp
示例17: makeMatch
string makeMatch(vs namesWomen, vs answersWomen, vs namesMen, vs answersMen, string queryWoman)
{
vp women;
vp men;
int size = namesWomen.size();
for(int i = 0; i<size; i++)
{
women.push_back(ps(namesWomen[i], answersWomen[i]));
men.push_back(ps(namesMen[i], answersMen[i]));
}
sort(women.begin(), women.end());
sort(men.begin(), men.end());
int compatible = 0;
vp dates;
for(vp::iterator it = women.begin(); it != women.end(); it++)
{
vp::iterator idealMale;
string wAnswer = it->second;
compatible = -1;
for(vp::iterator mit = men.begin(); mit != men.end(); mit++)
{
string mAnswer = mit->second;
int score = 0;
for(int x = 0; x < wAnswer.length(); x++)
{
if(wAnswer[x] == mAnswer[x])
score++;
}
if(score > compatible)
{
compatible = score;
idealMale = mit;
}
}
if(it->first == queryWoman)
return idealMale->first;
men.erase(idealMale);
}
string noMatch = "NO_MATCH";
return noMatch;
}
开发者ID:rusty34,项目名称:TopCoder,代码行数:51,代码来源:MatchMaking.cpp
示例18: find_openspaces
void find_openspaces(const vs &initial_map, pii *spaces) {
int count = 0;
for (int i = 0; i < initial_map.size(); i++) {
for (int j = 0; j < initial_map[i].size(); j++) {
if (initial_map[i][j] == '.') {
spaces[count] = make_pair(i+1, j+1);
count++;
if (count == 2) {
return;
}
}
}
}
}
开发者ID:toshihoge,项目名称:ACM-ICPC-Practice,代码行数:14,代码来源:e.cpp
示例19: printPredictionsAndCalculateAccuracy
/*
* Outputs the predictions to file
* and returns the accuracy of the classification
*/
double printPredictionsAndCalculateAccuracy(vs &givenData, vs &predictions)
{
ofstream outputFile;
outputFile.open("decisionTreeOutput.txt");
int correct = 0;
outputFile << setw(3) << "#" << setw(16) << "Given Class" << setw(31) << right << "Predicted Class" << endl;
outputFile << "--------------------------------------------------" << endl;
for (int iii = 0; iii < givenData.size(); iii++) {
outputFile << setw(3) << iii + 1 << setw(16) << givenData[iii];
if (givenData[iii] == predictions[iii]) {
correct++;
outputFile << " ------------ ";
}
else {
outputFile << " xxxxxxxxxxxx ";
}
outputFile << predictions[iii] << endl;
}
outputFile << "--------------------------------------------------" << endl;
outputFile << "Total number of instances in test data = " << givenData.size() << endl;
outputFile << "Number of correctly predicted instances = " << correct << endl;
outputFile.close();
return (double)correct / 50 * 100;
}
开发者ID:novaintel,项目名称:csci4125,代码行数:28,代码来源:functions.cpp
示例20: classification
/*
* function: naive_bayes::classification 对数据进行分类
* return: 该数据最可能的目标属性值
*
*/
std::string naive_bayes::classification(vs& data)
{
assert((int)data.size() == num_attr - 1);
// 为了防止溢出,以下对概率值取了对数
int max_index = -1;
double p_max = -1e300; // 最大概率
vd p_targ_val; // 每个目标属性值对该数据的概率 P(data | target_attr[i])
p_targ_val.resize(num_targ, 0.0);
auto f = [&](double x, double u, double d)
{// 求正态分布概率密度
return std::exp(-(x - u) * (x - u) / (2 * d)) / sqrt(4 * std::acos(-1) * d);
};
for(int i = 0; i < num_targ; ++i)
{
auto& t = p_targ_val[i];
t = std::log(p_target[i]); // 取对数
for(int j = 0; j < num_attr - 1; ++j)
{
auto& p = p_datas[i][j];
if(is_numeric[j])
{
t += std::log(f(std::stod(data[j]), p.mean_value, p.variance));
}
else
{
auto it = attr_to_int[j].find(data[j]);
if(it == attr_to_int[j].end())
{
std::cerr<<"No such attribute value."<<std::endl;
exit(1);
}
t += std::log(p.p_attr[it->second]);
}
}
}
// 找到最大概率值
for(int i = 0; i < num_targ; ++i)
{
// std::cout<<p_targ_val[i]<<std::endl;
if(p_max < p_targ_val[i])
p_max = p_targ_val[i], max_index = i;
}
return int_to_attr[num_attr - 1][max_index];
}
开发者ID:ecnumjc,项目名称:naive_Bayes,代码行数:49,代码来源:naive_bayes.cpp
注:本文中的vs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论