poj 2263 Heavy Cargo floyd基础,就是输入的时候处理字符串纠结一点!!!!
2011-11-17 03:24
483 查看
#include<iostream> using namespace std; int map[205][205],pri; char a[100],b[100]; char name[205][100]; int cou=0; int find()//寻找a字符串的位置 { for(int i=1;i<202;i++) { if(strcmp(name[i],a)==0) return i; } int len=strlen(a); for(int i=0;i<len;i++) { name[cou][i]=a[i]; } name[cou][len]='\0'; cou++; return cou-1; } int find1()//寻找b字符串的位置 { for(int i=0;i<202;i++) { if(strcmp(name[i],b)==0) return i; } int len=strlen(b); for(int i=0;i<len;i++) { name[cou][i]=b[i]; } name[cou][len]='\0'; cou++; return cou-1; } int main() { int n,m,cases=1; while(cin>>n>>m,n||m) { for(int i=0;i<202;i++) { for(int j=0;j<202;j++) map[i][j]=-1; } memset(name,0,sizeof(name)) ; cou=1; while(m--) { cin>>a>>b>>pri; int t1=find(); int t2=find1(); map[t1][t2]=map[t2][t1]=pri; // cout<<t1<<' '<<t2; // system("pause"); } for(int k=1;k<=n;k++)//floyd { for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) map[i][j]=max(map[i][j],min(map[i][k],map[k][j])); } } printf("Scenario #%d\n",cases++); cin>>a>>b; int t1=find(); int t2=find1(); // cout<<t1<<' '<<t2; // system("pause"); printf("%d tons\n\n",map[t1][t2]); } return 0; }
相关文章推荐
- Poj 2263 Heavy Cargo Floyd 求最大容量路
- poj2256人工智能?其实就是字符串处理啦
- javascript 数字相加的时候要进行一下处理,不然就是字符串相加
- 对双向链表的处理,单个,但是,有错误,就是在输入越界 时候,没有执行出错处理
- hdu 2263 Heavy Cargo Floyd(求最大容量)
- 描述 求一个字符串的最长递增子序列的长度 如:dabdbf最长递增子序列就是abdf,长度为4 输入 第一行一个整数0<n<20,表示有n个字符串要处理 随后的n行,每行有一个字符串,该字符串的长度不
- POJ 3094 字符串处理及空格输入
- gets与scanf关于字符串输入(特别是对换行符处理)的一点小解惑
- java基础 字符串处理
- 写一个类,能接受int型的变量,接收变量后能存储原变量和其反向变量,最多处理数量为10个,当输入达到10个或者输入变量为0的时候停止。
- poj 1035 Spell checker ( 字符串处理 )
- string.Format 输入的字符串格式有误的解决方法 中括号的处理办法
- POJ2993——Help Me with the Game(字符串处理+排序)
- Python3.4字符串基础及每次处理一个字符
- poj 2041 Unreliable Message 字符串处理
- MySQL 基础 —— 字符串处理
- 20161216C语言基础17_字符串处理函数之fgets与gets
- poj 2752 Seek the Name, Seek the Fame ---KMP,字符串处理
- POJ 2263 floyd思想
- HDU 1013 Digital Roots 数字根 字符串处理基础题