-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
730 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
3 1 2 3 | ||
5 10 15 20 30 50 | ||
4 100 200 300 400 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
11 17 23 30 50 | ||
100 200 300 400 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,9 @@ | ||
# Sequence Problem : Array Practice | ||
Time Limit: 1 Sec Memory Limit: 4 MB | ||
|
||
|
||
## Description | ||
整数序列是一串按特定顺序排列的整数,整数序列的长度是序列中整数的个数,不可定义长度为负数的整数序列。 | ||
# nce Problem : Array Practice | ||
时间限制: 1 Sec 内存限制: 4 MB | ||
题目描述整数序列是一串按特定顺序排列的整数,整数序列的长度是序列中整数的个数,不可定义长度为负数的整数序列。 | ||
两整数序列A、B的和定义为一个新的整数序列C,序列C的长度是A、B两者中较长的一个,序列C的每个位置上的整数都是A、B对应位置之和。若序列A、B不等长,不妨假设A比B整数多,那么序列C中多出B的那部分整数视作A的对应位置上的整数与0相加。 | ||
你的任务是计算符合某些要求的整数序列的和,这些序列中的整数都是小于1000的非负整数。 | ||
|
||
## Input | ||
输入为多行,直到文件末尾结束。每行第一个整数为N(N<=1000),后接一个长度为N的整数序列。 | ||
|
||
## Output | ||
对输入的整数序列两两相加:第1行和第2行相加、第3行和第4行相加……按顺序输出结果:每行输出一个整数序列,每两个整数之间用一个空格分隔。若序列数目不为偶数,则视作补一个长度为0的整数序列相加。 | ||
值得注意的是一个长度为0的整数序列也应该有输出,即使没有整数输出,也应该占有一行,因为“每行输出一个整数序列”。 | ||
|
||
## Sample Input | ||
``` | ||
3 1 2 3 | ||
你的任务是计算符合某些要求的整数序列的和,这些序列中的整数都是小于1000的非负整数。输入输入为多行,直到文件末尾结束。每行第一个整数为N(N<=1000),后接一个长度为N的整数序列。输出对输入的整数序列两两相加:第1行和第2行相加、第3行和第4行相加……按顺序输出结果:每行输出一个整数序列,每两个整数之间用一个空格分隔。若序列数目不为偶数,则视作补一个长度为0的整数序列相加。 | ||
值得注意的是一个长度为0的整数序列也应该有输出,即使没有整数输出,也应该占有一行,因为“每行输出一个整数序列”。样例输入3 1 2 3 | ||
5 10 15 20 30 50 | ||
4 100 200 300 400 | ||
``` | ||
## Sample Output | ||
``` | ||
11 17 23 30 50 | ||
100 200 300 400 | ||
``` | ||
|
||
## HINT | ||
这里最少要用到一个数组来存数整数序列或整数序列的和。 | ||
4 100 200 300 400样例输出11 17 23 30 50 | ||
100 200 300 400提示这里最少要用到一个数组来存数整数序列或整数序列的和。 |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 行之和 | ||
时间限制: 1 Sec 内存限制: 16 MB | ||
题目描述编写一个程序,求矩阵各行元素值相加之和。其中,矩阵的元素都是很小的整数,且各行元素之和的数值不会超出int类型的表示范围。 | ||
输入输入为多行。第一行K>0,表示有K个测试用例。 | ||
之后K个测试用例中,首先是两个整数0<=M,N<=100,表示该测试用例的矩阵是一个M行N列的矩阵。之后是一个M行N列的整数组成的矩阵。 | ||
输出输出有K行,每个测试用例的结果占一行。每行的格式为: | ||
case i:d1 d2 ... dj | ||
其中i表示测试用例的编号(从1开始),d1、d2、....、dj表示相应测试用例的各行的和,两两之间用空格隔开。 | ||
样例输入4 | ||
3 3 | ||
1 2 3 | ||
1 2 3 | ||
1 2 3 | ||
2 3 | ||
1 1 1 | ||
1 1 1 | ||
1 1 | ||
1 | ||
5 1 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7样例输出case 1:6 6 6 | ||
case 2:3 3 | ||
case 3:1 | ||
case 4:3 4 5 6 7提示 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
123 321 | ||
555 555 | ||
123456789 987654321 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0 | ||
3 | ||
9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 小学生算术 | ||
Time Limit: 1 Sec Memory Limit: 16 MB | ||
|
||
|
||
## Description | ||
给出两个正整数,计算两个数相加需要多少次进位。 | ||
|
||
|
||
|
||
## Input | ||
数据有多组,每组包含两个整数,都在int范围内,输入以EOF结尾 | ||
|
||
|
||
## Output | ||
|
||
一个整数,表示两个数相加需要的进位次数 | ||
|
||
|
||
## Sample Input | ||
``` | ||
123 321 | ||
555 555 | ||
123456789 987654321 | ||
``` | ||
## Sample Output | ||
``` | ||
0 | ||
3 | ||
9 | ||
``` | ||
|
||
## HINT | ||
一定要用整数求余相加判断吗?想想有没有简洁的思路。试试用字符串吧,转换思路,分步处理。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
2 Look! | ||
5 I love china! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
2 Look! | ||
2 Look! | ||
5 I love china! | ||
5 I love china! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 编写函数:字符串的复制 之一 (Append Code) | ||
Time Limit: 1 Sec Memory Limit: 2 MB | ||
|
||
|
||
## Description | ||
将输入的一个字符串s拷贝输出。 | ||
----------------------------------------------------------------------------- | ||
编写一个函数str_cpy()求一个串的拷贝: | ||
原型:char * str_cpy(char * t, char * s); | ||
功能:把串s复制到串t中,返回值是串t。 | ||
函数的调用格式见“Append Code”。 | ||
----------------------------------------------------------------------------- | ||
Invalid Word(禁用单词)错误:在解决这个题目时,某些关键词是不允许被使用的。如果提交的程序中包含了下列的关键词之一,就会产生这个错误。 | ||
被禁用的头文件:string.h、stdlib.h。 | ||
被禁用的库函数:strcpy()、strncpy()、memcpy()等。 | ||
|
||
|
||
## Input | ||
|
||
输入为多行。每行为一个字符串s。s的字符总数不超过100个。 | ||
|
||
|
||
|
||
## Output | ||
串s的复制。 | ||
输出两遍,一遍是测试返回值,一遍是测试str。 | ||
|
||
|
||
## Sample Input | ||
``` | ||
2 Look! | ||
5 I love china! | ||
``` | ||
## Sample Output | ||
``` | ||
2 Look! | ||
2 Look! | ||
5 I love china! | ||
5 I love china! | ||
``` | ||
|
||
## HINT | ||
str_cpy()的返回值参考标准库函数strcpy()、strstr()、strchr()的设计思路:返回指向目标串的指针。 | ||
|
||
## Append Code | ||
### append.c | ||
```c | ||
int main() | ||
{ | ||
char s[MAX_STR_LEN], str[MAX_STR_LEN], *p; | ||
while(gets(s) != NULL) | ||
{ | ||
p = str_cpy(str, s); | ||
puts(p); | ||
puts(str); | ||
} | ||
return 0; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
abcdefg | ||
12345678 | ||
XYZ | ||
abc 123 | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
abcdefg | ||
12345678 | ||
XYZ | ||
abc 123 | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 编写函数:清除字符串首尾的空白符 (Append Code) | ||
Time Limit: 1 Sec Memory Limit: 2 MB | ||
|
||
|
||
## Description | ||
|
||
|
||
|
||
在C语言中,将ASCII字符集中的制表符('\t')、回车符('\r')、换行符('\n')、垂直制表符('\v')、换页符('\f')和空格字符(' ')称作空白符。你的任务是读入每行字符串,去掉行首和行尾的连续空白符,但是在任意非空白符中间的空白符不要去除。 | ||
----------------------------------------------------------------------------- | ||
编写一个函数trim(),把一个串首尾的空白符清除掉: | ||
原型:char * trim(char *s); | ||
功能:去掉字符串s首尾的连续空白符,s中在任意非空白符中间的空白符不要去除,并将s的首地址返回。 | ||
函数的调用格式见“Append Code”。 | ||
|
||
|
||
|
||
## Input | ||
输入为多行,每行为一个串(不超过100个字符),至某行输入的非空白符仅为“END”结束。 | ||
|
||
|
||
## Output | ||
输出为多行,为每行输入的去掉前后空白符的串。“END”也输出。 | ||
|
||
|
||
|
||
## Sample Input | ||
``` | ||
abcdefg | ||
12345678 | ||
XYZ | ||
abc 123 | ||
END | ||
``` | ||
## Sample Output | ||
``` | ||
abcdefg | ||
12345678 | ||
XYZ | ||
abc 123 | ||
END | ||
``` | ||
|
||
## HINT | ||
下面这些说法都是一个意思:“返回一个字符串S”、“返回字符串S的指针”、“返回字符串S的首地址”。 | ||
|
||
## Append Code | ||
### append.c | ||
```c | ||
int main() | ||
{ | ||
char str[MAX_STR_LEN], *p; | ||
do | ||
{ | ||
gets(str); | ||
p = trim(str); | ||
puts(p); | ||
} while(strcmp(p, "END")); | ||
return 0; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ABCDE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
EDCBA | ||
EDCBA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# 编写函数:字符串的逆序串 (Append Code) | ||
Time Limit: 1 Sec Memory Limit: 2 MB | ||
|
||
|
||
## Description | ||
|
||
将输入的一个字符串s逆序输出。 | ||
|
||
----------------------------------------------------------------------------- | ||
编写一个函数str_rev()求一个串的逆序串: | ||
原型:char * str_rev(char * t, char * s); | ||
功能:把串s逆序复制到串t中,返回值是逆序串t。 | ||
函数的调用格式见“Append Code”。 | ||
|
||
|
||
|
||
## Input | ||
输入为一个串s。输入最少为一个字符,最多不会超过100个字符。 | ||
|
||
|
||
## Output | ||
串s的逆序。 | ||
输出两遍,一遍是测试返回值,一遍是测试str。 | ||
|
||
|
||
## Sample Input | ||
``` | ||
ABCDE | ||
``` | ||
## Sample Output | ||
``` | ||
EDCBA | ||
EDCBA | ||
``` | ||
|
||
## HINT | ||
str_rev()的返回值参考标准库函数strcpy()、strstr()、strchr()的设计思路:返回指向目标串的指针。 | ||
|
||
## Append Code | ||
### append.c | ||
```c | ||
int main() | ||
{ | ||
char s[MAX_STR_LEN], str[MAX_STR_LEN], *p; | ||
gets(s); | ||
p = str_rev(str, s); | ||
puts(p); | ||
puts(str); | ||
return 0; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
2 | ||
1 2 | ||
10 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
3 = 1 + 2 | ||
30 = 10 + 20 |
Oops, something went wrong.