• PAT乙级1072-----开学寄语 (20分)


    1072 开学寄语 (20分)

    输入样例:

    4 2
    2333 6666
    CYLL 3 1234 2345 3456
    U 4 9966 6666 8888 6666
    GG 2 2333 7777
    JJ 3 0012 6666 2333
    
     

    输出样例:

    U: 6666 6666
    GG: 2333
    JJ: 6666 2333
    3 5


    思路:
    1.用数组下标表示违禁物品编号
    2.不满4位数要补0,例如:编号12输出时为0012


    首次通过代码:
     1 #include<stdio.h>
     2 
     3 int main(){
     4     int n,m;int num[10004]={0};
     5     scanf("%d %d",&n,&m);
     6     for(int i=0;i<m;i++){
     7         int a;
     8        scanf("%d",&a);
     9        num[a]=1;
    10     }
    11     int counter_student=0;int counter_goods=0;
    12     for(int i=0;i<n;i++){
    13         char name[6];int a;int c1=0;
    14         scanf("%s %d",name,&a);
    15         for(int j=0;j<a;j++){
    16             int b;
    17             scanf("%d",&b);
    18             if(num[b]==1){
    19                 if(c1==0) {
    20                   if(counter_student!=0) printf("
    ");
    21                   printf("%s: ",name);
    22                   if(b<1000&&b>=100) printf("0"); 
    23                   else if(b<100&&b>=10) printf("00");
    24                   else if(b<10)  printf("000");
    25                   printf("%d",b);
    26                   counter_student++;c1++;
    27                 }
    28                 else {
    29                   printf(" ");
    30                   if(b<1000&&b>=100) printf("0"); 
    31                   else if(b<100&&b>=10) printf("00");
    32                   else if(b<10)  printf("000");
    33                  printf("%d",b);
    34                  c1++;
    35                 }
    36             }
    37         }
    38         counter_goods+=c1;
    39     }
    40     if(counter_student>0) printf("
    %d %d",counter_student,counter_goods);
    41     else printf("0 0");
    42     return 0;
    43 }
    View Code
     
  • 相关阅读:
    ui5 call view or method from another view
    vuejs helloworld
    vuejs v-model
    vuejs v-bind
    vuejs on
    vuejs fatherandson
    vuejs scope
    vuejs keep-alive
    VLAN虚拟局域网
    网线的制作
  • 原文地址:https://www.cnblogs.com/a982961222/p/12386431.html
Copyright © 2020-2023  润新知