栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++ 11.09

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++ 11.09

1、

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

2、

#include
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
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
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
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
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
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;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/458060.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号