请帮忙!我无法产生程序的输出。这是这样的条件:如果购买的衬衫是XL并且价格大于500,则构造一个程序,可提供100比索的折扣;如果购买的衬衫是L并且价格大于600,则可享受50比索的折扣。
#include <iostream>
using namespace std;
int main()
{
int p;
int s;
cout << "Input price: ";
cin >> p;
cout << "Input size: ";
cin >> s;
switch (s)
{
case 'XL': case 'xl':
{
if (p>500){
cout << "Total price: " << p-100 << " pesos.";
break;
}
else if ((s=='XL' || s=='xl') && (p<500)){
cout << "Total price: " << p << " pesos.";
break;
}
}
case 'L': case 'l':
{
if (p>600){
cout << …
Run Code Online (Sandbox Code Playgroud) 我需要一些帮助.我想计算x给定的实数值a和正值整数x.
我的节目:
#include <iostream>
using namespace std;
int main()
{
int a, x;
cout << "Input a: ";
cin >> a;
cout << "Input x: ";
cin >> x;
for (int i=0; i<=x; i++)
a= a*a;
cout << "The answer is: " << a;
}
Run Code Online (Sandbox Code Playgroud)