结构体的使用 for循环使用方式 sort 使用

1.创建结构体

    成员变量 多个

    成员函数 多个

    其他结构体 多个

2.定义结构体变量

    结构体名 变量名

3.调用   .成员访问符

 

 

for循环:

for(1.初始条件;2.循环条件3.条件改变){

  4.表达式

}

while:

1

while(2){

  4  

  3

}

 sort 使用

#include <bits/stdc++.h>

using namespac std;

int mian(){

  int a[5]={1,3,4,6,5};

  sort (a,a+5);

  for(int i=0;i<5;i++){

    cout<<a[i]<<" ";

  }

}

 

  

posted @ 2024-12-08 09:28  最后一个还有我  阅读(16)  评论(0)    收藏  举报