review

#include <iostream>
using namespace std;
#include <string>
#include "swap.h"
void bb( int arr1[], int len)//数组传入时特殊 传入的就是地址,所以不能做形参
{
    for (int i=0; i < len - 1; i++)
    {
        for (int a = 0; a < len - 1 - i; a++)
        {
            if (arr1[a] >= arr1[a + 1])
            {
                int temp = arr1[a];
                arr1[a] = arr1[a + 1];
                arr1[a + 1] = temp;
            }
            
        }
    }
    for (int i = 0; i < len ; i++)
    {
        cout << arr1[i] ;
    }

}
int main()
{
    //for (int a = 0; a < 10; a++)
    //{
    //    if (a % 2 == 0)
    //    {
    //        continue;
    //        break;//直接跳出  for  循环
    //    }
    //    else
    //    {
    //        cout << a << endl;
    //    }
    //    
    //}
    /*int arr[][3] = {1,2,3,4,5,6};
    cout << arr[1][1] << endl;*/

    /*int score[][3] = {100,100,100,90,90,90,80,80,80};
    string stu[3] = {"A","B","C"};
    for (int i = 0; i < sizeof(stu) / sizeof(stu[0]); i++)
    {
        cout << stu[i] << "的成绩是" << endl;
        int sum = 0;
        for (int a = 0; a < sizeof(score[0]) / sizeof(score[0][0]); a++)
        {
            sum += score[i][a];
        }
        cout << sum << endl;
    }*/

    /*int arr[2][2] = { 1,2,3,1 };
    cout << arr << endl;
    cout << &arr[0][0] << endl;*/

    //int a = 10;
    //int b = 20;
    //swap(a,b);
    头文件 .h 
     #pragma once   
     函数声明
     
    源文件 .cpp      
    #include "头.h"
    #include <iostream>
    .......   

    /*int* p = (int*)1000;

    cout << *p << endl;*/

    //int a = 10;
    //int b = 100;
    //const int* p = &a;
    *p = 500;//常量指针不能改内容
    //p = &b;
    //cout << *p << endl;

    //int* const p1 = &a;
    //*p1 = 500;
    p1 = &a;//指针常量不行改地址
    //cout << *p1 << endl;
    int arr[5] = {1,9,5,7,6};
    int len = 0;
    len = sizeof(arr) / sizeof(arr[0]);
    bb(arr, len);
    cout << "------------------" << endl;
    for (int i = 0; i < len; i++)
    {
        cout << arr[i] ;
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值