return 0;
}
二、 文件输出流类 ofstream
ofstream是文件输出流类的类名。定义一个该类的对象,即可将该对象和一个文件建立联系。例如,
ofstream fout(“”)
表示定义一个文件输出流类的对象fout,并将该对象与当前目录下的文件建立联系,以后可以用该对象向中输出数据。
文件输出流类对象的使用与cout的使用完全相同。
三、编程(来源:浙江工业大学/)
1、
ACM训练网站:A+B Problem
Time Limit:1000MS Memory Limit:1024K
Description:
Calculate a + b
Input:
The input will consist of a series of pairs of integers a and b,separated
by a space, one pair of integers per line, 0 0 means the end of the input,
and do not need to output.
Output:
For each pair of input integers a and b you should output the sum of a
and b in one line,and with one line of output for each line in input.
Sample Input:
1 5
0 0
Sample Output:
6
2、逆反的01串
Time Limit:1000MS Memory Limit:32768K
Description:
Fans是个ACM程序设计迷。有时侯,他表现出很强烈的逆反心理,你往东,他往西,你往南,他偏往北。这一次,不知道又是谁惹着他了,好端端的一个个01串,到了他的手里,都变成10串了。请你编个程序来模仿他的行为,将01串(长度≤200),全变成10串吧。
Sample Input:
0
1000000
Sample Output:
1
1111111
3、神奇的fans
Time Limit:1000MS Memory Limit:32768K
Description:
传说fans是一个数学天才。在他五岁那年,从一堆数字卡片中选出了4张卡片:5,7,6,8。这4个数字有什么神秘之处呢?如果把这4张卡片自左往右的排成:5,6,7,8。你就会发现:原来这4个数字构成了等差数列!当年fans选出了n组卡片,据说都能够构成等差数列。但是事实真的是这样吗?fans真的有这么神奇吗? n组数据就是fans选出的n组卡片,请你判断每一组卡片是否能构成等差数列,如果能够构成等差数列,输出“yes”,否则输出“no”。文件中第一个数为数据的组数n,表示后面有n行,每行中的第一个数为该组数据的元素个数m(1≤m≤100),其后是m个正整数(不会超出int的表示范围)。
Sample Input:
2
4 5 7 6 8
8 1 7 3 2 8 12 78 3
Sample Output:
yes
no
4、对称串
Time Limit:1000MS Memory Limit:32768K
Description:
有一些字串,有些对称,有些不对称,请将对称的串按长度排列。
Sample Input:
123321
123454321
123
321
sdfsdfd
121212
dd
Sample Output:
123321
dd
123454321
发布评论