printf请输入一句以感叹号结尾的英文句子 ; scanfc&p;
There seems to be a mistake in your code. The variable 'p' should be declared as a character array or string to store the input sentence. Here's the corrected code:
#include <stdio.h>
int main() {
char sentence[100];
printf("请输入一句以感叹号结尾的英文句子: ");
scanf("%[^\n]s", sentence);
// Check if the sentence ends with an exclamation mark
if (sentence[strlen(sentence) - 1] == '!') {
printf("输入的句子正确!\n");
} else {
printf("输入的句子不以感叹号结尾!\n");
}
return 0;
}
This code prompts the user to enter a sentence and then checks if the sentence ends with an exclamation mark. The result is printed accordingly
原文地址: https://www.cveoy.top/t/topic/hU1v 著作权归作者所有。请勿转载和采集!