KiKi非常喜欢网购,在一家店铺他看中了一件衣服,他了解到,如果今天是“双11”(11月11日)则这件衣服打7折,“双12” (12月12日)则这件衣服打8折,如果有优惠券可以额外减50元(优惠券只能在双11或双12使用),求KiKi最终所花的钱数。
数据范围:衣服价格满足 
一行,四个数字,第一个数表示小明看中的衣服价格,第二和第三个整数分别表示当天的月份、当天的日期、第四个整数表示是否有优惠券(有优惠券用1表示,无优惠券用0表示)。 注:输入日期保证只有“双11”和“双12”。
一行,小明实际花的钱数(保留两位小数)。(提示:不要指望商家倒找你钱)
1000.0 11 11 1
650.00
999.8 12 12 0
799.84
66.6 11 11 1
0.00
#include<stdio.h>
int main()
{
float price,sum;
int month,day,flag;
scanf("%f%d%d%d",&price,&month,&day,&flag);
if(month==11&&day==11)
{
sum=0.7*price;
if(flag==1)
{
if(sum>=50)
sum-=50;
else
sum=0;
}
}
else if(month==12&&day==12)
{
sum=0.8*price;
if(flag==1)
{
if(sum>=50)
sum-=50;
else
sum=0;
}
}
else
{
sum=price;
}
printf("%.2f",sum);
return 0;
} #include<stdio.h>
int main()
{
double y,jg;int month,day,flag=0;
scanf("%lf%d%d%d",&y,&month,&day,&flag);
if(month==11&&day==11)
{
jg=y*0.7;
if(flag==1)
jg-=50;
}
if(month==12&&day==12)
{
jg=y*0.8;
if(flag==1)
jg-=50;
}
if(jg<0)
printf("0.00");
else
printf("%.2f",jg);
} #include<iostream>
#include<iomanip>
using namespace std;
int main(void)
{
float a, b, c, d;
while (cin >> a >> b >> c >> d)
{
if (b == 11 && c == 11)
{
a = 0.7 * a;
}
else if (b == 12 && c == 12)
{
a = 0.8 * a;
}
if (d == 1)
{
a -= 50;
if (a < 0)
{
a = 0;
}
}
cout << fixed << setprecision(2) << a << endl;
}
return 0;
} import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
double price = in.nextDouble();
int month = in.nextInt();
int day = in.nextInt();
int coupon = in.nextInt();
if(month==day&&month==12){
price = price*0.8;
}
if(month==day&&month==11){
price = price*0.7;
}
if(coupon==1){
price = price - 50;
}
System.out.printf("%.2f",price>0?price:0.0);
}
} import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str[] = sc.nextLine().split(" ");
if(str[1].equals("11")&&str[2].equals("11")){
double money = Double.parseDouble(str[0]);
double realmoney = money*0.7;
if(str[3].equals("1")){
realmoney = realmoney - 50;
if(realmoney<0){
realmoney = 0;
}
}
System.out.printf("%.2f",realmoney);
}
else if(str[1].equals("12")&&str[2].equals("12")){
double money = Double.parseDouble(str[0]);
double realmoney = money*0.8;
if(str[3].equals("1")){
realmoney = realmoney - 50;
if(realmoney<0){
realmoney = 0;
}
}
System.out.printf("%.2f",realmoney);
}
else{
double money = Double.parseDouble(str[0]);
double realmoney = money;
System.out.printf("%.2f",realmoney);
}
}
} import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
double price=input.nextDouble();
int mm=input.nextInt();
int dd=input.nextInt();
int flag=input.nextInt();
if(mm==11&&dd==11) price*=0.7;
else if(mm==12&&dd==12) price*=0.8;
if(flag==1)price-=50;
price=price<0?0:price;
System.out.println(String.format("%.2f",price));
}
}
#include <iostream>
int main()
{
float tr;
int month , date , yn;
scanf("%f %d %d %d",&tr, &month, &date, &yn);
float num;
if(month == 11 && date == 11)
{
if(yn == 1)
num = tr * 0.7 - 50;
else
num = tr * 0.7;
}
if(month == 12 && date == 12)
{
if(yn == 1)
num = tr * 0.8 - 50;
else
num = tr * 0.8;
}
if(num <= 0.0)
printf("0.00");
else
printf("%.2f",num);
return 0;
} #include <stdio.h>
int main()
{
float price, disc;
int mon, day, discount;
scanf("%f%d%d%d", &price, &mon, &day, &discount);
if(mon == 11 && day == 11)
disc = 0.7;
else if(mon == 12 && day == 12)
disc = 0.8;
else
disc = 1;
price *= disc;
if(discount)
price -= 50;
if(price < 0)
price = 0;
printf("%.2f\n", price);
} #include<stdio.h>
int main() {
double price;
int month,date,have;
scanf("%lf%d%d%d",&price,&month,&date,&have);
int two11 = month==11&&date==11,two12 =month==12&&date==12;
if(two11) price*=0.7;
if(two12) price*=0.8;
if(have&&(two11||two12)) price-=50;
printf("%.2lf",price<0?0:price);
} 11行,应该算比较简洁了
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int month,day,coupon;
float price;
cin>>price>>month>>day>>coupon;
float discount;
bool cou_flag=false;
if(month==11&&day==11)
{
discount=0.7;
cou_flag=true;
}
else if(month==12&&day==12)
{
discount=0.8;
cou_flag=true;
}
else
discount=1;
price=price*discount;
if(cou_flag&&coupon==1)
{
if(price>50)
cout<<fixed<<setprecision(2)<<price-50<<endl;
else
cout<<fixed<<setprecision(2)<<0.00<<endl;
}
else
cout<<fixed<<setprecision(2)<<price<<endl;
return 0;
}
int main()
{
double a;
int b,c,d;
scanf("%lf%d%d%d",&a,&b,&c,&d);
if(b==11&&c==11)
{
if(d==1)
{
if(0.7*a-50<=0)
{
printf("0.00");
}
else
{
printf("%.2lf",0.7*a-50);
}
}
else
{
printf("%.2lf",0.7*a);
}
}
if(b==12&&c==12)
{
if(d==1)
{
if(0.8*a-50<=0)
{
printf("0.00");
}
else
{
printf("%.2lf",0.8*a-50);
}
}
else
{
printf("%.2lf",0.8*a);
}
}
} #include <stdio.h>
int main()
{
double arr[4] = { 0 };
int i = 0;
for(i = 0; i < 4; i++)
{
scanf("%lf ",&arr[i]);
}
double money = 0;
money = arr[0];
if(arr[1] == 11 &&arr[2] == 11)
{
money = arr[0]*0.7-arr[3]*50;
}
if(arr[1] == 12 && arr[2] == 12)
{
money = arr[0]*0.8 - arr[3] *50;
}
if(money > 0)
printf("%.2lf", money);
else
printf("0.00");
return 0;
} #include <stdio.h>
int main()
{
int m = 0;
int d = 0;
int flag = 0;
float money = 0.0f;
scanf("%f%d%d%d", &money, &m, &d, &flag);
//双12
if(12 == m && 12 == d)
{
money *= 0.8;
}
//双11
else if(11 == m && 11 == d)
{
money *= 0.7;
}
//优惠券
if(flag)
{
money -= 50;
//查看是否倒找钱
//因为倒找钱的情况只会出现在有优惠券的情况下,所有放在此循环内
if(money < 0)
{
money = 0;
}
}
printf("%.2f\n", money);
return 0;
} #include <stdio.h>
int main() {
double money;
int a, b, c;
while (scanf("%lf %d %d %d", &money, &a, &b, &c) != EOF)
{
double sum=0;
if(a==11&&b==11)
{
sum=(money*0.7);
}else if((a==12&&b==12))
{
sum=(money*0.8);
}
if((c==1&&a==11&&b==11)||(c==1&&a==12&&b==12))
sum=sum-50;
if(sum>0)
printf("%.2lf\n",sum);
else
printf("%.2lf\n",0.00);
}
return 0;
}