题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2090
Windows下的EOF结束符为Ctrl + Z
代码如下:
1 #include <cstdio> 2 using namespace std; 3 4 int main() 5 { 6 double num, price; 7 char s[20]; 8 double sum = 0; 9 while(scanf("%s %lf %lf", s, &num, &price) != EOF) 10 { 11 sum += num * price; 12 } 13 printf("%.1lf\n", sum); 14 return 0; 15 }