文章目录
一、题目
输入格式:
输出格式:
输入样例1:
输出样例1:
输入样例2:
输出样例2:
输入样例3:
输出样例3:
二、方法1
1、思路
本题唯一需要注意的就是我们是以 “.” 来结束输出的:
strcmp(name, ".") != 0
2、代码
#include<stdio.h>
#include<string.h>
int main()
{
int count = 0;
char name[20], A[20], B[20];
while (scanf("%s", name) && strcmp(name, ".") != 0)
{
count++;
if (count == 2)
{
strcpy(A, name);
}
if (count == 14)
{
strcpy(B, name);
}
}
if (count >= 14)
{
printf("%s and %s are inviting you to dinner...", A, B);
}
else if (count >= 2)
{
printf("%s is the only one for you...", A);
}
else
{
printf("Momo... No one is for you ...");
}
return 0;
}