a) 'A' <= cl <= 'Z' b) (c1 >= A)&& (cl <= Z) c) A <= cl <= Z d) (c1 >= 'A') && (cl <= 'Z'),关键是要编程序证明这个选项,不明白怎么编程
第1个回答 2018-09-18
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define A 0
#define Z 0
#define ChoiceAmount 4
typedef bool (* choiceFunction_t)(const char);
static const char *upperString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char *lowerString = "abcdefghijklmnopqrstuvwxyz";
static const char *choiceName = "ABCD";
static bool ChoiceA(const char cl);
static bool ChoiceB(const char cl);
static bool ChoiceC(const char cl);
static bool ChoiceD(const char cl);
int main(int argc, char *argv[])
{
choiceFunction_t choiceArr[] = {ChoiceA, ChoiceB, ChoiceC, ChoiceD};
bool isCorrect[] = {true, true, true, true};
for(unsigned int functionIndex = 0; functionIndex < ChoiceAmount; functionIndex++)
for(unsigned int letterIndex = 0; upperString[letterIndex] != '\0'; letterIndex++)
if(!choiceArr[functionIndex](upperString[letterIndex]))
isCorrect[functionIndex] = false;
for(unsigned int functionIndex = 0; functionIndex < ChoiceAmount; functionIndex++)
for(unsigned int letterIndex = 0; upperString[letterIndex] != '\0'; letterIndex++)
if(choiceArr[functionIndex](lowerString[letterIndex]))
isCorrect[functionIndex] = false;
for(unsigned choiceIndex = 0; choiceIndex < ChoiceAmount; choiceIndex++)
fprintf(stdout, "Choice%c is %s.\n", choiceName[choiceIndex], isCorrect[choiceIndex]?"correct":"incorrect");
return EXIT_SUCCESS;
}
static bool ChoiceA(const char cl) { return 'A' <= cl <= 'Z'; }
static bool ChoiceB(const char cl) { return (cl >= A) && (cl <= Z); }
static bool ChoiceC(const char cl) { return A <= cl <= Z; }
static bool ChoiceD(const char cl) { return(cl >= 'A') && (cl <= 'Z'); }
#include <stdlib.h>
#include <stdbool.h>
#define A 0
#define Z 0
#define ChoiceAmount 4
typedef bool (* choiceFunction_t)(const char);
static const char *upperString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char *lowerString = "abcdefghijklmnopqrstuvwxyz";
static const char *choiceName = "ABCD";
static bool ChoiceA(const char cl);
static bool ChoiceB(const char cl);
static bool ChoiceC(const char cl);
static bool ChoiceD(const char cl);
int main(int argc, char *argv[])
{
choiceFunction_t choiceArr[] = {ChoiceA, ChoiceB, ChoiceC, ChoiceD};
bool isCorrect[] = {true, true, true, true};
for(unsigned int functionIndex = 0; functionIndex < ChoiceAmount; functionIndex++)
for(unsigned int letterIndex = 0; upperString[letterIndex] != '\0'; letterIndex++)
if(!choiceArr[functionIndex](upperString[letterIndex]))
isCorrect[functionIndex] = false;
for(unsigned int functionIndex = 0; functionIndex < ChoiceAmount; functionIndex++)
for(unsigned int letterIndex = 0; upperString[letterIndex] != '\0'; letterIndex++)
if(choiceArr[functionIndex](lowerString[letterIndex]))
isCorrect[functionIndex] = false;
for(unsigned choiceIndex = 0; choiceIndex < ChoiceAmount; choiceIndex++)
fprintf(stdout, "Choice%c is %s.\n", choiceName[choiceIndex], isCorrect[choiceIndex]?"correct":"incorrect");
return EXIT_SUCCESS;
}
static bool ChoiceA(const char cl) { return 'A' <= cl <= 'Z'; }
static bool ChoiceB(const char cl) { return (cl >= A) && (cl <= Z); }
static bool ChoiceC(const char cl) { return A <= cl <= Z; }
static bool ChoiceD(const char cl) { return(cl >= 'A') && (cl <= 'Z'); }
第2个回答 2018-09-18
#include<stdio.h>
int main()
{
char c1='D';
if((c1 >= 'A') && (cl <= 'Z'))
{
printf("yes\n");
}
else
{
printf("no\n");
}
return 0;
}本回答被提问者采纳
int main()
{
char c1='D';
if((c1 >= 'A') && (cl <= 'Z'))
{
printf("yes\n");
}
else
{
printf("no\n");
}
return 0;
}本回答被提问者采纳