1 solutions

  • 0
    @ 2021-10-30 11:30:44

    这道题比较中规中矩,典型的结构体,注意保留两位小数和不存在满足条件商品的情况

    #include<stdio.h>
    #include<string.h>
    struct goods
    {
    	int a;
        double b;
    	char c[101];
    	
    }arr[101];
    int main()
    {
    	int a,b,m,p,flag=1;
    	scanf("%d %d",&m,&p);
    	for(int i=0;i<m;i++)
    	{
    		scanf("%d %lf %s",&arr[i].a,&arr[i].b,&arr[i].c);
    	}
    	for(int i=0;i<m;i++)
        if(arr[i].b>p)
        {
        	flag=0;
        	 printf("%d ",arr[i].a);
        	 printf("%.2f ",arr[i].b);
        	 printf("%s\n",arr[i].c);
    	}
       if(flag)
       printf("QAQ\n");
    return 0;
    }
    

    Information

    ID
    144
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    179
    Accepted
    27
    Uploaded By