一道蓝桥杯题对于处理输入的启发
来源:互联网 发布:苏州php招聘 编辑:程序博客网 时间:2024/05/18 22:15
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int n,a[10000],i,len,j;
char s[100];
int main()
{
cin >> n;
gets(s);
len = 0;
int k = -1;
for(i = 0; i<n; i++)
{
gets(s+1);
s[0] = ' ';
int flag = 0;
for(j = 0; s[j]; j++)
{
if(s[j-1] == ' ' && s[j]!=' ')
{
k = s[j]-'0';
flag = 1;
}
else if(s[j] == ' ')
{
if(k!=-1)
a[len++] = k;
flag = 0;
k = -1;
}
else if(flag)
k = k*10+s[j]-'0';
}
}
if(k!=-1)
a[len++] = k;
sort(a,a+len);
int x = 0,y = 0;
for(i = 1;i<=len;i++)
{
if(a[i] == a[i-1])
y = a[i];
else if(a[i]-a[i-1] == 2)
x = a[i-1]+1;
}
cout << x << " " << y << endl;
return 0;
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int n,a[10000],i,len,j;
char s[100];
int main()
{
cin >> n;
gets(s);
len = 0;
int k = -1;
for(i = 0; i<n; i++)
{
gets(s+1);
s[0] = ' ';
int flag = 0;
for(j = 0; s[j]; j++)
{
if(s[j-1] == ' ' && s[j]!=' ')
{
k = s[j]-'0';
flag = 1;
}
else if(s[j] == ' ')
{
if(k!=-1)
a[len++] = k;
flag = 0;
k = -1;
}
else if(flag)
k = k*10+s[j]-'0';
}
}
if(k!=-1)
a[len++] = k;
sort(a,a+len);
int x = 0,y = 0;
for(i = 1;i<=len;i++)
{
if(a[i] == a[i-1])
y = a[i];
else if(a[i]-a[i-1] == 2)
x = a[i-1]+1;
}
cout << x << " " << y << endl;
return 0;
}
找缺号和重号
样例输入1
2
5 6 8 11 9
10 12 9
5 6 8 11 9
10 12 9
样例输出1
7 9
样例输入2
6
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 125 129 168 196
172 189 127 107 112 192 103 131 133 169 158
128 102 110 148 139 157 140 195 197
185 152 135 106 123 173 122 136 174 191 145 116 151 143 175 120 161 134 162 190
149 138 142 146 199 126 165 156 153 193 144 166 170 121 171 132 101 194 187 188
113 130 176 154 177 120 117 150 114 183 186 181 100 163 160 167 147 198 111 119
164 178 108 109 180 155 141 159 104 182 179 118 137 184 115 124 125 129 168 196
172 189 127 107 112 192 103 131 133 169 158
128 102 110 148 139 157 140 195 197
185 152 135 106 123 173 122 136 174 191 145 116 151 143 175 120 161 134 162 190
149 138 142 146 199 126 165 156 153 193 144 166 170 121 171 132 101 194 187 188
113 130 176 154 177 120 117 150 114 183 186 181 100 163 160 167 147 198 111 119
样例输出2
105 120
0 0
- 一道蓝桥杯题对于处理输入的启发
- 对于字符输入的处理
- UVA 196 一道好玩的输入处理+拓扑排序题
- 对于输入字符串数组的处理,三维数组
- symfony2中对于输入时间进行查询,时间的处理。
- 百度《2014网报》对于网站建设的启发
- 一道输入流的问题
- 对于压缩文件的处理
- 对于事件的处理
- 对于权限的处理
- 对于时间的处理
- 思维启发之根据一道题的算法发现自己的思维局限性
- 一道java入门题——多项式加法给我的启发
- 对于render system的一点思考(里面关于材质的ID很有启发)
- ACM简单题目中对于连续多组输入的处理方法
- 一道字符输入/输出的问题
- xpath 对于 comments的处理
- Oracle对于天数的处理
- ListView源码分析(二)
- LeetCode : Ransom Note
- 元素为指针的vector的使用说明
- Java8系列之重新认识HashMap
- Node中require()的原理
- 一道蓝桥杯题对于处理输入的启发
- poj3168(扫描线)
- LICEcap方便快捷制作gif图片的工具
- 412. Fizz Buzz
- drawableTop,button图片显示在文字上面,文字不显示的问题
- Apple Catching POJ
- Linux Min
- 参考了下别的文章..springMVC也可以这么写
- 每天一个 Linux 命令(5):rm 命令