diff --git a/2207/C语言同步练习源码/5.指针-4.c b/2207/C语言同步练习源码/5.指针-4.c new file mode 100644 index 0000000..85aeb8d --- /dev/null +++ b/2207/C语言同步练习源码/5.指针-4.c @@ -0,0 +1,23 @@ +#include +#include + +int main(){ + char str[5][20]; + char (*p)[20], (*max)[20];// (*)[];ָ + int i; + for(i=0, p =str;i<5;i++){ + scanf("%s", p++); + } + max = p; + + for(i=1, p =str+1;i<5;i++){ + if(strcmp(*p, *max)){ + max = p; + } + p++; + } + printf("max = %s\n", max); + + return 0; +} + diff --git a/2207/C语言同步练习答案.md b/2207/C语言同步练习答案.md index b3b7d24..3c1f595 100644 --- a/2207/C语言同步练习答案.md +++ b/2207/C语言同步练习答案.md @@ -836,6 +836,32 @@ int main(){ ![image-20250227231243197](https://yp.smallkun.cn/markdown/image-20250227231243197.png!compress) +```c +#include +#include + +int main(){ + char str[5][20]; + char (*p)[20], (*max)[20];//数据类型 (*变量名)[长度];数组指针 + int i; + for(i=0, p =str;i<5;i++){ + scanf("%s", p++); + } + max = p; + + for(i=1, p =str+1;i<5;i++){ + if(strcmp(*p, *max)){ + max = p; + } + p++; + } + printf("max = %s\n", max); + + return 0; +} + +``` + ## 编译预处理