结构体里的数比较大小

/*结构体里的数比较大小,只可以用小于号,不可以用大于号只能在p<a.p(升序)改a.p<p(降序)*/
#include<iostream>
#include <conio.h>
#include<algorithm>
using namespace std;
struct node
{
    int p;
    bool operator < (const node &a)const
    {    
        return p<a.p;
    }

};
int main()
{
    node no[7]={1,2,9,4,8,6,7};
    sort(no,no+7);
    for(int i=0;i<7;i++)
        cprintf("%d\n",no[i]);
    char c;
    cin>>c;
    c=tolower(c);//大写转换成小写
    printf("%c\n",c);
    return 0;
}
原文地址:https://www.cnblogs.com/heqinghui/p/2711027.html