#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
char type1, grind1, cream1;
int wght1;
double temp1;
char type2, grind2, cream2;
int wght2;
double temp2;
printf("COFFEE-1...\n");
printf("Type ([L]ight,[B]lend): ");
scanf("%c", &type1);
printf("Grind size ([C]ourse,[F]ine): ");
scanf(" %c", &grind1);
printf("Bag weight (g): ");
scanf(" %d", &wght1);
printf("Best served with cream ([Y]es, [N]o): ");
scanf(" %c", &cream1);
printf("Ideal serving temperature (Celcius): ");
scanf(" %.1lf", &temp1);
printf("\n");
printf("COFFEE-2...\n");
printf("Type ([l]ight,[B]lend): ");
scanf(" %c", &type2);
printf("Grind size ([C]ourse,[F]ine): ");
scanf(" %c", &grind2);
printf("Bag weight (g): ");
scanf(" %d", &wght2);
printf("Best served with cream ([Y]es,[N]o): ");
scanf(" %c", &cream2);
printf("Ideal serving temperature (Celcius): ");
scanf(" %.1lf", &temp2);
printf("\n");
return(0);
}
我可以輸入 type1、grind1、wght1、cream1 和 temp1 的值,但不是第二次........我是編碼新手,我的作業明天到期 welp T_T
uj5u.com熱心網友回復:
格式說明符%.1lf不正確。
與printf格式說明符不同,scanf格式說明符不采用精度,因此請將其洗掉。
scanf(" %lf", &temp1);
...
scanf(" %lf", &temp2);
uj5u.com熱心網友回復:
對我來說,我會編碼兩次“printf”和“scanf”,以便輸入兩次值。
uj5u.com熱心網友回復:
請使用 fflush(stdin) 清除鍵盤緩沖區。在 temp1 輸入后,請輸入下一行
重繪 (標準輸入)
那么接下來的陳述就是......
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/419663.html
標籤:
