UVa 201
来源:互联网 发布:mac最小化快捷键 编辑:程序博客网 时间:2024/05/07 00:04
背景:1Y!!!调试一个小时。没有仔细看题,V 2 1,实际上表示的是第二列第一行,因为这个调试了好久。要逐渐养成耐心读代码的习惯!
思路:把行和列的分别记录在两个数组你,让后从边长为1开始枚举出所有即可!
学习:1.scanf读取字符的时候一定要考虑到,换行行符在键盘缓冲区的遗留问题!
#include<stdio.h>#include<string.h>int main(void){#ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);#endif int count=1,t,h,v,side; while(~scanf("%d",&side)){ side--; if(count-1) printf("\n**********************************\n\n"); printf("Problem #%d\n\n",count++); int horizontal[11][11],vertical[11][11]; scanf("%d%*c",&t); memset(horizontal,0,sizeof(horizontal)); memset(vertical,0,sizeof(vertical)); while(t--){ char direction; scanf("%c%d%d%*c",&direction,&h,&v); if(direction == 'H') horizontal[h][v]=1; else vertical[v][h]=1; } bool have=true; for(int i=1;i <= side;i++){ int ans=0; for(int j=1;j <= side+1-i;j++){ for(int k=1;k <=side+1-i;k++){ bool ok=true; for(int ii=0;ii < i;ii++){ if(!horizontal[j][k+ii]) ok=false; if(!horizontal[j+i][k+ii]) ok=false; if(!vertical[j+ii][k]) ok=false; if(!vertical[j+ii][k+i]) ok=false; } if(ok) ans++; } } if (ans){ printf("%d square (s) of size %d\n",ans,i); have=false; } } if(have) printf("No completed squares can be found.\n"); } return 0;}
0 0
- UVa 201
- uva-201
- Uva 201
- uva 201
- uva 201
- UVA 201
- UVa 201
- UVA-201Squares
- UVa 201 - Squares
- UVa 201 - Squares
- UVa 201 - Squares
- UVA-201 Squares
- UVA - 201 Squares
- Uva 201 Squares
- UVa-201Squares
- UVa 201 Squares
- UVA - 201 Squares
- UVA 201 Squares
- sql2008评估期已过。有关如何升级您的测试版软件的信息
- [经典面试题][百度]在由N个正整数的集合S中,找出最大元素C,满足C=A + B
- cocos2dx 读取json及解析
- C++调用外部exe问题总结
- oracle查看数据库锁,诊断锁的来源及类型
- UVa 201
- 【2015-2】day1 cerc 2008
- Android开发中Intent的一些总结
- iOS基础学习之一:第一个hello world
- Configuring GRUB to boot the right kernel after an upgrade
- LeetCode --- Construct Binary Tree from Preorder and Inorder Traversal
- UVa 10562 - Undraw the Trees
- oracle性能优化总结
- LeetCode—*Fraction to Recurring Decimal