主页

2008.数值统计

Problem Problem Description 统计给定的n个数中,负数、零和正数的个数。 Input 输入数据有多组,每组占一行,每行的第一个数是整数n(n<100),表示需要统计的数值的个数,然后是n个实数;如果n=0,则表示输入结束,该行不做处理。 Output 对于每组输入数据,输出一行a,b和c,分别表示给定的数据中负数、零和正数的个数。 Sample Input 6 0 1 2 3 -1 0 5 1 2 3 4 0.5 0 Sample Output 1 2 3 0 0 5 Solution #include<stdio.h> int main(void) { int count,i; int zhengshu,fush...

阅读更多

2011.多项式求和

Problem Problem Description 多项式的描述如下: 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + … 现在请你求出该多项式的前n项的和。 Input 输入数据由2行组成,首先是一个正整数m(m<100),表示测试实例的个数,第二行包含m个正整数,对于每一个整数(不妨设为n,n<1000),求该多项式的前n项的和。 Output 对于每个测试实例n,要求输出多项式前n项的和。每个测试实例的输出占一行,结果保留2位小数。 Sample Input 2 1 2 Sample Output 1.00 0.50 Solution #include<stdio.h> int main(void) { int c...

阅读更多

2006.求奇数的乘积

Problem Problem Description 给你n个整数,求他们中所有奇数的乘积。 Input 输入数据包含多个测试实例,每个测试实例占一行,每行的第一个数为n,表示本组数据一共有n个,接着是n个整数,你可以假设每组数据必定至少存在一个奇数。 Output 输出每组数中的所有奇数的乘积,对于测试实例,输出一行。 Sample Input 3 1 2 3 4 2 3 4 5 Sample Output 3 15 Solution #include<stdio.h> int main() { int i,num,j,c,a; while(scanf("%d",&num)!=EOF){ a=1; ...

阅读更多

2003.求绝对值

Problem Problem Description 求实数的绝对值。 Input 输入数据有多组,每组占一行,每行包含一个实数。 Output 对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。 Sample Input 123 -234.00 Sample Output 123.00 234.00 Solution #include<stdio.h> #include<math.h> int main() { double num; while(scanf("%lf",&num)!=EOF){ num=fabs(num); printf("%.2lf\n",num);...

阅读更多

1093.A+B for Input-Output Practice (V)

Problem Problem Description Your task is to calculate the sum of some integers. Input Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. Output For each group of input integers you should output their sum in one line, and with one line of out...

阅读更多

1095.A+B for Input-Output Practice (VII)

Problem Problem Description Your task is to 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. Output For each pair of input integers a and b you should output the sum of a and b, and followed by a blank line. Sample Input 1 5 10 20 Sample Output 6 3...

阅读更多

1092.A+B for Input-Output Practice (IV)

Problem Problem Description Your task is to Calculate the sum of some integers. Input Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed. Output For each group of input integers you shou...

阅读更多

1091.A+B for Input-Output Practice (III)

Problem Problem Description Your task is to Calculate a + b. Input Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed. Output For each pair of input integers a and b you should output th...

阅读更多

1090.A+B for Input-Output Practice (II)

Problem Problem Description Your task is to Calculate a + b. Input Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line. Output For each pair of input integers a and b you should output the sum of a and b in one line, and ...

阅读更多

2000.ASCII码排序

Problem Problem Description 输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。 Input 输入数据有多组,每组占一行,有三个字符组成,之间无空格。 Output 对于每组输入数据,输出一行,字符中间用一个空格分开。 Sample Input qwe asd zxc Sample Output e q w a d s c x z Solution #include<stdio.h> int main(void) { int a,b,c,t,u; char q,w,e; while(scanf("%c%c%c",&q,&w,&e)!=EOF){ ...

阅读更多

2004.成绩转换

Problem Problem Description 输入一个百分制的成绩t,将其转换成对应的等级,具体转换规则如下: 90~100为A; 80~89为B; 70~79为C; 60~69为D; 0~59为E; Input 输入数据有多组,每组占一行,由一个整数组成。 Output 对于每组输入数据,输出一行。如果输入数据不在0~100范围内,请输出一行:“Score is error!”。 Sample Input 56 67 100 123 Sample Output E D A Score is error! Solution #include<stdio.h> int main(void) { int t; while(scanf("%d",&...

阅读更多

2002.计算球体积

Problem Problem Description 根据输入的半径值,计算球的体积。 Input 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。 Output 输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。 Sample Input 1 1.5 Sample Output 4.189 14.137 Hint #define PI 3.1415927 Solution #include<stdio.h> #define PI 3.1415927 int main(void) { double r,tiji; while(scanf("%lf",&r)!=EOF){ tiji=...

阅读更多

2009.求数列的和

Problem Problem Description 数列的定义如下: 数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。 Input 输入数据有多组,每组占一行,由两个整数n(n<10000)和m(m<1000)组成,n和m的含义如前所述。 Output 对于每组输入数据,输出该数列的和,每个测试实例占一行,要求精度保留2位小数。 Sample Input 81 4 2 2 Sample Output 94.73 3.41 Solution #include<stdio.h> #include<math.h> int main(void) { int m,n,i; double sum,sqr; while(sc...

阅读更多

2001.计算两点间的距离

Problem Problem Description 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离。 Input 输入数据有多组,每组占一行,由4个实数组成,分别表示x1,y1,x2,y2,数据之间用空格隔开。 Output 对于每组输入数据,输出一行,结果保留两位小数。 Sample Input 0 0 0 1 0 1 1 0 Sample Output 1.00 1.41 Solution #include<stdio.h> #include<math.h> int main(void) { float x1,y1,x2,y2,line; while(scanf("%f %f %f %f",&...

阅读更多

1001.Sum Problem

Problem Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + … + n. 计算1 + 2 + 3 + …… + n的值 Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You ma...

阅读更多