题解 | 找最小数

找最小数

https://www.nowcoder.com/practice/72d0910e837a4a6e95c7f4d60e6d0e68

#include <stdio.h>
typedef struct data{
    int x;
    int y;
}data;
int main() {
    int a, b,n;
   scanf("%d", &n) ;
   data  c[n];
   for(int i=0;i<n;i++)
    { 
        scanf("%d %d\n",&c[i].x,&c[i].y);
        // 注意 while 处理多个 case
        // 64 位输出请用 printf("%lld") to 
       // printf("%d\n", a + b);
    }
    data temp=c[0];
    for(int i=0;i<n;i++){
if(temp.x>c[i].x){ temp.x=c[i].x;temp.y=c[i].y;a=i;}
if(temp.x==c[i].x&&temp.y>c[i].y){temp.x=c[i].x;temp.y=c[i].y;}
    }
    printf("%d %d",temp.x,temp.y);
    return 0;
}

主要看数据结构会不会写

全部评论

相关推荐

03-06 18:20
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务