The code below just needs to output the sum = unit1 * price1 + unit2 * price2 ; I don't need the code1,code2 of goods. I don't know how to skip them in my program? I did not know - so i had to read them and store them in code1, code2.How to ignore them?
I tried to do cin >> >> unit1 >> price1 ;
but it says "error". I can't just do it!
#include <iostream>
using namespace std ;
int main(){
int code1 ;
int code2 ;
int unit1 ;
int unit2 ;
float price1 ;
float price2 ;
cin >> code1 >> unit1 >>price1 ;
cin >> code2 >> unit2 >>price2 ;
float result = unit1 * price1 + unit2*price2 ;
printf("to pay: R$ %.2f\n" ,result ) ;
}
If you only need the last 2 integers, define only two integers, a1 and a2.
int a1, a2;
scanf("%d%d%d", &a1, &a1, &a2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.