C++ 11.09
发布日期:2022-03-16 03:25:46 浏览次数:26 分类:技术文章

本文共 1754 字,大约阅读时间需要 5 分钟。

1、

#include<iostream>

using namespace std;
int main()
{
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if (i >= j)
            {
                cout << j<<"*"<<i<<" ";
            }
        }
        cout << endl;
    }
    system("pause");
    return 0;
}

2、

#include<iostream>

using namespace std;
int main()
{
    int num = 0;
    cout << "1、简单" << endl;
    cout << "2、中等" << endl;
    cout << "3、困难" << endl;
    cout << "请选择难度" << endl;
    cin >> num;
    switch (num)
    {
    case 1:
        cout << "你选择的是简单" << endl;
        break;
    case 2:
        cout << "你选择的是中等" << endl;
        break;
    case 3:
        cout << "你选择的是困难" << endl;
        break;
    }
    system("pause");
    return 0;
}

3、

#include<iostream>

using namespace std;
int main()
{
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            if (j == 5)
            {
                break;
            }
            cout << 1;
        }
        cout << endl;
    }
    system("pause");
    return 0;
}

4、

#include<iostream>

using namespace std;
int main()
{
    for (int i = 0; i <= 100; i++)
    {
        if (i % 2 == 0)
        {
            continue;
        }
        cout << i << endl;
    }
    system("pause");
    return 0;
}
5、

#include<iostream>

using namespace std;
int main()
{
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
    goto A;
    cout << 4 << endl;
    A:
    cout << 5 << endl;
    system("pause");
    return 0;
}

6、

#include<iostream>

using namespace std;
int main()
{
    int arr[4];
    arr[0] = 1;
    arr[1] = 2;
    arr[2] = 3;
    arr[3] = 4;
    int arr2[4] = { 1,2,3,4 };
    int arr3[] = { 1,2,3,4 };
    for (int i = 0; i < 4; i++)
    {
        cout << arr[i] << endl;
    }
    cout << sizeof(arr) << endl;
    cout << sizeof(arr[1]) << endl;
    cout << arr << endl;
    cout << (int)arr << endl;
    cout << &arr[1] << endl;
    cout << (int)&arr[1] << endl;
    system("pause");
    return 0;
}

7、

#include<iostream>

using namespace std;
int main()
{
    int max = 0;
    int arr[] = { 300,350,200,450,250 };
    for (int i = 0; i < 5; i++)
    {
        if (arr[i] > max)
        {
            max = arr[i];
        }
    }
    cout << max << endl;
    system("pause");
    return 0;
}

转载地址:https://blog.csdn.net/zhizhikaodigua/article/details/121235521 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:C++ 10.29
下一篇:MATLAB中的复杂矩阵输入问题

发表评论

最新留言

不错!
[***.144.177.141]2024年04月22日 16时12分26秒