《c語言程式設計》習題.賬單處理
阿新 • • 發佈:2020-12-29
我的版本
#include <stdio.h>
int main()
{
int n, i;
char *p;
double price, sum = 0;
char str[10000];
scanf("%d", &n);
getchar();
for (i = 0; i < n; i++)
{
gets(str);
p = str;
while (*p > 57 || *p == 32)
{
p++ ;
/* code */
}
sscanf(p, "%lf", &price);//從字元陣列p中讀取一個double型別的資料存入變數f
sum += price;
p = str;
/* code */
}
printf("%.1lf\n", sum);
}
書上的待補充