- 621 名前:デフォルトの名無しさん mailto:sage [2010/07/07(水) 23:54:42 ]
- #include <stdio.h>
int main() { int unit_price; // 単価 int num; // 個数 printf( "買う商品の単価: " ); scanf( "%d", &unit_price ); printf( "個数: " ); scanf( "%d", &num ); int total_price = unit_price * num; // 小数を使うと誤差がでるので使わない if ( num >= 20 ) total_price = total_price*6/10; else if ( num >= 10 ) total_price = total_price*8/10; else if ( num >= 5 ) total_price = total_price*9/10; printf( "合計金額: %d", total_price ); } エラー Z:\プログラミング演習\sample\ensyu8\ensyu8.c(14) : error C2143: 構文エラー : ';' が 'type' の前に必要です。 Z:\プログラミング演習\sample\ensyu8\ensyu8.c(18) : error C2065: 'total_price' : 定義されていない識別子です。 cl.exe の実行エラー これもお願いします。
|

|