zoukankan      html  css  js  c++  java
  • hdoj1571

    下沙小面的(1)
    代码
    #include<iostream>
    #include
    <stdio.h>
    #include
    <string.h>
    using namespace std;
    int NCity, T, dist[30][30], K, pn, ans, P[7], now;    //dist距离,pn人数,now现在的车站
    int main()
    {
        
    while (scanf("%d"&NCity) != EOF && NCity) {
        pn 
    = 0, now = 0, ans = 0;
        
    for (int i = 0; i < NCity; ++i)
            
    for (int j = 0; j < NCity; ++j)
            scanf(
    "%d"&dist[i][j]);
        scanf(
    "%d"&K);
        
    char ch1, ch2;
        
    while (K--) {
            cin 
    >> ch1 >> ch2;
            
    if (ch1 == 'U') {    //有人上车
            scanf("%d"&T);
            
    if (pn == 7 || T == now)
                
    continue;    //人満
            P[pn] = T;
            pn
    ++;
            } 
    else {        //开车
            if (pn == 0)
                
    continue;
            ans 
    += dist[now][P[0]];
            now 
    = P[0];
            
    int tem[7];
            
    int ptem = 0;
            
    for (int pos = 0; pos < pn; ++pos) {
                
    if (P[pos] == now) {
                
    continue;
                }
                tem[ptem
    ++= P[pos];
            }
            
    for (int pos = 0; pos < ptem; ++pos)
                P[pos] 
    = tem[pos];
            pn 
    = ptem;
            }
        }
        printf(
    "%d\n", ans);
        }
    }


  • 相关阅读:
    最近比较毁硬件
    如何编写 Visual C++ 的表达式分析插件
    Windows 安全性编程
    MMX写的memcpy测试
    今天终于摆平了DeskBand
    ASP.NET后台代码调用前台javascript脚本的方法
    ArcGIS Server 9.3前后台交互调用实现点定位
    Oracle中建立存储过程
    建表时自动增加oracle表中记录的ID值
    特定图层的渲染
  • 原文地址:https://www.cnblogs.com/Open_Source/p/1904954.html
Copyright © 2011-2022 走看看