• 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;
    }
  • 相关阅读:
    mongo的常用操作——增删改查
    配置我的sublime
    mongo概念
    mongo命令
    mongo安装与配置
    node搭建http基本套路
    模块的导出入
    vue数据绑定原理
    webpack打包速度优化
    工作中的优化之数字键盘优化
  • 原文地址:https://www.cnblogs.com/rainydays/p/1982670.html
Copyright © 2020-2023  润新知