发布网友 发布时间:2024-09-28 13:40
共1个回答
热心网友 时间:2024-10-16 16:18
这一段程序代码的功能就是计算字符串数组中最大的字符串长度。len=7
char* a[5]={"student","worker","cadre","soldier","peasant"};高手帮...这一句的意思是:定义一个char类型的指针数组,也就是说,在a[5]这个数组中有5个字符型的指针元素,然后将{"student","worker","cadre","soldier","peasant"}分别赋值给这五个指针。结果是a[0]="student",a[1]="worker",a[2]="cadre",a[3]="soldier",a[4]="pessant"。
char* a[5]={"student","worker","cadre","soldier","peasant"};高手帮...你的因该是C语言吧!include "stdio.h"%库函数申明 include "string.h""%库函数申明 main()%主函数 { int i;%变量定义 char* a[5]={"student","worker","cadre","soldier","peasant"};%用数组保存后米娜的5项 char *p1, *p2;%指针变量的定义 p1=p2=a[0];%指定初始值 for(i=0;...
三道程序运行题求解。。。请带分析p1=p[0];//则p1=“student”for(){ if(strcmp(a[i],p1)>0){ //如果a[i] 按字符排序排在p1(“student”)后面 //按字符顺序排序为apen—>cadre—>soldier—>student—>worker p1=a[i];//当a[i]=“worker”时,满足strcmp(“worker”, “student”)>0所以结果p1=“worker”} } 3...
C++新手指针习题程序运行结果如下:apen cadre soldier student worker 答案:(1)char *p[],int n (2)*temp (3)p[j],p[j+1])>0 (4)p[j]=p[j+1]4.函数find功能是:在指针p所指数组中,查找值为x的元素,找到后,返回该元素的下标,否则返回-1,改正程序中语句错误,能够正确运行。include<iostream>...