7-8 Programmers buy buns

7-8 Programmers buy buns

score 10

Browse topics in full screen

switch layout

Author Chen Yue

Unit Zhejiang University

This is a joke to test real programmers: If you are asked by your family to buy ten buns on the way off work, if you see a watermelon, buy one. So under what circumstances would you only buy a steamed stuffed bun to take home?
This question requires you to consider the general version of this joke: If you are asked to buy N buns on the way off work, if you see one selling X, buy M buns. So if you finally bought K steamed stuffed buns and went home, did you see those selling X?

Input format:

Enter N, X, M, K in the title in sequence in one line, separated by spaces. Among them, N, M and K are positive integers not exceeding 1000, and X is a string consisting of only lowercase English letters with a length not exceeding 10. The title guarantees that N=M.

Output format:

Output the conclusion on one line in the format:

  • If K=N, output  mei you mai X de;
  • If K=M, output  kan dao le mai X de;
  • Otherwise output  wang le zhao mai X de.
    where  X is the string X given in the input.

Input sample 1:

10 xigua 1 10

Output sample 1:

mei you mai xigua de

Input sample 2:

10 huanggua 1 1

Output sample 2:

kan dao le mai huanggua de

Input sample 3:

10 shagua 1 250

Output sample 3:

wang le zhao mai shagua de

code length limit

16 KB

time limit

400 ms

memory limit

64 MB

#include <stdio.h>
#include <string.h>

int main() {
    int N, M, K;
    char X[11];

    // 输入 N、X、M、K
    scanf("%d %s %d %d", &N, X, &M, &K);

    // 比较最后购买的包子数量 K 和题目要求的数量 N、M,输出相应的结果
    if (K == N) {
        printf("mei you mai %s de\n", X);
    } else if (K == M) {
        printf("kan dao le mai %s de\n", X);
    } else {
        printf("wang le zhao mai %s de\n", X);
    }

    return 0;
}

Guess you like

Origin blog.csdn.net/m0_73879806/article/details/131644147