1.  >>  高等继续教育 / 高级语言程序设计
 高等继续教育 / 高级语言程序设计
正确率:郑大成教%

下列程序段的结果为()。

typedef struct {

    char city[50];

    float temperature;

} Weather;

 

int main() {

    Weather weatherData[3] = {{"Beijing", -5.0}, {"Shanghai", 10.0}, {"Guangzhou", 20.0}};

    char searchCity[] = "Shanghai";

    int found = 0;

    for (int i = 0; i < 3; i++) {

        if (strcmp(weatherData[i].city, searchCity) == 0) {

            found = 1;

            break;

        }

    }

    if (found) {

        printf("Found\n");

    } else {

        printf("Not Found\n");

    }

    return 0;

}



Not Found


Found


运行时错误,内存访问违规


编译错误,结构体数组不能初始化

 参考答案:
 佳题速递: