URAL 2046 The First Day at School(模拟)
来源:互联网 发布:java c 效率 编辑:程序博客网 时间:2024/05/18 18:54
题目链接:
URAL 2046
题目大意:
给出一个课程表,用程序画出它来
题目分析:
模拟,STL大法好,比较好调…..
AC代码:
#include <iostream>#include <cstring>#include <cstdio>#include <iomanip>#include <algorithm>#include <vector>#include <string>#define MAX 10000;using namespace std;string s;int n;int grid[10][10];int h[10];vector<string> v[20];string p[]={"Tuesday","Thursday","Saturday"};bool check ( string s1 , string s2 ){ int len1 = s1.length(); int len2 = s2.length(); if (len1 != len2 ) return false; for ( int i = 0 ; i < len1 ; i++ ) if ( s1[i] != s2[i] ) return false; return true;}int main ( ){ while ( ~scanf ( "%d" , &n ) ) { memset ( grid , -1 , sizeof ( grid )); for ( int i = 1 ; i <= n ; i++ ) { v[i].clear(); int col,row; cin >> s; while ( true ) { bool flag = false; for ( int j = 0 ; j < 3 ; j++ ) if ( !s.compare ( p[j] ) ) { col = j+1; flag = true; break; } if ( flag ) break; else v[i].push_back ( s ); cin >> s; } cin >> row; grid[row][col] = i; } for ( int i = 1 ; i <= n ; i++ ) { int len = v[i].size(); int id = 0; vector<string> temp; string ss = ""; for ( int j = 0 ; j < len ; j++ ) if ( ss == "" ) { ss += v[i][j]; } else if ( v[i][j].length() + ss.length() < 10 ) { ss +=" "; ss += v[i][j]; } else { temp.push_back ( ss ); ss = v[i][j]; } temp.push_back ( ss ); v[i].clear(); for ( int j = 0 ; j < temp.size() ; j++ ) v[i].push_back ( temp[j] ); } for ( int i = 1 ; i <= 4 ; i++ ) { h[i] = 1; } for ( int i = 1 ; i <= 4 ; i++ ) { for ( int j = 1 ; j <= 3 ; j++ ) if ( grid[i][j] != -1 ) { int len = v[grid[i][j]].size(); h[i] = max ( h[i] , len ); } } for ( int k = 1 ; k <= 4 ; k++ ) { cout << "+----------+----------+----------+" << endl; for ( int j = 1 ; j <= h[k] ; j++ ) { for ( int i = 1 ; i <= 3 ; i++ ) { int id = grid[k][i]; if ( id == -1 ) cout <<setw(11)<<left<<"|"; else if ( v[id].size() < j ) cout <<setw(11)<<left<<"|"; else cout <<left<< "|" << setw(10) << v[id][j-1]; } cout << "|" << endl; } } cout << "+----------+----------+----------+" << endl; }}
0 0
- URAL 2046 The First Day at School(模拟)
- ural 2046 The First Day at School
- The First Day at School
- Timus 2046 The First Day at School 非常好的一道模拟题
- URAL2046 The First Day at School
- B. Queue at the School
- Coderforces Queue at the School
- First Day at this Blog
- Day at the Race
- The first day!
- the first day!!!
- The first day...
- The First Day
- The first day
- The first day
- csdn the first day
- The first day~
- The first day
- Android_打开DDMS没有文件夹显示
- 学习记录
- 素因子分解
- Java 8 种数据类型 字节大小,int 4个字节,boolean几个字节
- 快学Hibernate
- URAL 2046 The First Day at School(模拟)
- HDU 2821Pusher(DFS )
- 周赛-kiki's game
- hibernate与spring的配置参考
- poj3322 Bloxorz I(滚箱子游戏) 状压BFS
- Struts配置参考
- 【POJ3181】【Dollar Dayz】
- 周赛-The Number Off of FFF
- 黑马程序员——面向对象