avg.c
#include <stdio.h>
int main()
{
int s,n;
scanf("%d,%d", &s, &n);
float v = s / n;
printf("v=%.2f \n", v);
return 0;
}
input.c
#include <stdio.h>
int main()
{
int flag = 1;
int i;
int count;
int sum = 0;
while(flag) {
scanf("%d", &i);
if(0 == i) break;
count++;
sum += i;
}
printf("%d,%d\n", sum, count);
return 0;
}
执行
#将input.out的输出流当做avg.out的输入流
[root@VM_0_8_centos les2]# ./input.out | ./avg.out
10
5
2
7
0
v=6.00
[root@VM_0_8_centos les2]#
网友评论