小编Jem*_*eal的帖子

交换语句C ++中的字符

请帮忙!我无法产生程序的输出。这是这样的条件:如果购买的衬衫是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)

c++ constants character switch-statement output

4
推荐指数
2
解决办法
5万
查看次数

使用循环在C++中的指数

我需要一些帮助.我想计算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)

c++ math loops exponent

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×2

character ×1

constants ×1

exponent ×1

loops ×1

math ×1

output ×1

switch-statement ×1