• poj3095


    简单的模拟

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cmath>
    using namespace std;

    #define maxn 100

    string st;
    int n;

    bool left(int a)
    {
    for (int i = a - 1; i >= 0; i--)
    {
    if (st[i] == '|' || st[i] == '\\' || st[i] == '/')
    return false;
    if (st[i] == '.')
    return true;
    }
    return true;
    }

    bool right(int a)
    {
    for (int i = a + 1; i < n; i++)
    {
    if (st[i] == '|' || st[i] == '\\' || st[i] == '/')
    return false;
    if (st[i] == '.')
    return true;
    }
    return true;
    }

    int main()
    {
    //freopen("D:\\t.txt", "r", stdin);
    while (getline(cin, st) && st != "#")
    {
    n
    = st.length();
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
    if (st[i] == '_')
    {
    sum
    += 0;
    continue;
    }
    if (st[i] == '.')
    {
    sum
    += 100;
    continue;
    }
    if (st[i] == '/')
    {
    sum
    += left(i) * 100;
    continue;
    }
    if (st[i] == '\\')
    {
    sum
    += right(i) * 100;
    continue;
    }
    if (st[i] == '|')
    {
    sum
    += left(i) * 50 + right(i) * 50;
    continue;
    }
    }
    cout
    << int(sum / double(n)) << endl;
    }
    return 0;
    }
  • 相关阅读:
    克隆对象和对象的继承
    面向对象的目的和方式
    补充+复习
    正则的一些细节和拖拽时遇到的问题及解决方法
    js高级正则解析
    正则理解
    如何判断this指向?
    动画以及运动
    元素节点
    null和undefined的区别
  • 原文地址:https://www.cnblogs.com/rainydays/p/1982670.html
Copyright © 2020-2023  润新知