UVA_414:Machined Surfaces




Language : C++ 4.8.2
#include<stdio.h>
#include<string.h>
int main(void)
{
int n;
int sum; // 记录每一组数据里面所有空格的个数
int count; // 记录单行的个数
int length;
int min_space;
char str[];
while()
{
min_space = ;
sum = ;
scanf("%d\n", &n); // 注意这里scanf里面的'\n',它不是那种常见的bug,而是为下面的fgets做铺垫的,否则fgets的第一次读取会向str中填充一个换行符然后以'\0'结尾。
if(n == )
break;
int m = n;
while(m--) // 一开始没有保存n的值,而是直接n--,导致后面printf计算的时候杯具了,输出结果一看,立即意识到了这块有问题,遂改之。
{
count = ;
fgets(str, sizeof(str), stdin);
length = strlen(str) - ; // fgets读取字符长度和实际字符长度在空间足够的情况下是有差别的。
for(int i = ; i < length; i++)
{
if(str[i] == ' ')
{
sum++;
count++;
}
}
if(min_space > count)
min_space = count;
}
printf("%d\n", sum-n*min_space);
} return ;
}
UVA_414:Machined Surfaces的更多相关文章
- uva414 - Machined Surfaces
uva414 - Machined Surfaces /* 水题,值得一提的是,getline使用时注意不能让它多吃回车键,处理方法可以用getchar. */ #include <iostre ...
- UVa 414 - Machined Surfaces
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- 414 - Machined Surfaces
Sample Input (character "B" for ease of reading. The actual input file will use the ASCII- ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 【索引】Volume 0. Getting Started
AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- <<Differential Geometry of Curves and Surfaces>>笔记
<Differential Geometry of Curves and Surfaces> by Manfredo P. do Carmo real line Rinterval I== ...
随机推荐
- 创建Hadoop用户
- 调用本地摄像头并通过canvas拍照
首先我们需要新建一个video标签,并且放到html里边 var video = document.createElement("video"); video.autoplay=& ...
- 读书笔记--Hibernate in Action 目录
1.理解对象/关系持久化 2.启动项目 3.领域模型和元数据 4.映射持久化类 5.继承和定制类型 6.映射集合和实体关联 7.高级实体关联映射 8.遗留数据库和定制SQL 9.使用对象 10.事务和 ...
- 7 个令人兴奋的 JavaScript 新特性
前言 一个ECMAScript标准的制作过程,包含了Stage 0到Stage 4五个阶段,每个阶段提交至下一阶段都需要TC39审批通过.本文介绍这些新特性处于Stage 3或者Stage 4阶段,这 ...
- ifconfig配置IP地址和子网掩码
ifconfig eth0 192.168.2.10 ifconfig eth0 192.168.2.10 netmask 255.255.255.0
- js对象类型判断工具
对象类型判断工具 /** *类功能:对象类型判断工具 **/ var TypeUtil = { /** *方法说明:是否是数组 **/ isArray: function (obj) {//是否是数组 ...
- Codeforces 1150D(字符串dp)
反思 三维的dp压根没看出来,看题解以后思路又很直观,找几道字符串dp练练才行 序列自动机和优化一维略 /* __ __ * ____| |_____| |____ * | | * | __ | * ...
- 洛谷 3398 仓鼠找sugar——树链剖分
题目:https://www.luogu.org/problemnew/show/P3398 原来只要把值记录成第几次就行了. 别忘了while(top[a]!=top[b])之后还要走一步. #in ...
- 当spark遇见hbase
一.使用sbt引入hbase依赖包 "org.apache.hbase" % "hbase-server" % "2.1.0", " ...
- excel怎么并排查看两个工作表
excel怎么并排查看两个工作表 excel怎么并排查看两个工作表?excel打开一个窗口想要同时查看两个工作表中的数据,类似于word中的分栏效果,该怎么实现呢?EXCEL是一个使用最多的办公软件, ...