![](https://lstatic.shangxueba.com/jiandati/h5/images/m_q_title.png)
编写一个函数,从传人的M个字符中找出最长的一个字符串,并通过形参指针max传回该串地址(用****作为结束输入的标志)。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的花括号中填人所编写的若干语句。 试题程序: include<stdio.h> include<string.h> include<conio.h> char*proc(char(*a)[81],int num) { } void main { char ss[l0][81],*max; int n,i=0; printf("输入若干个字符串:"); gets(ss[i]); puts(ss[i]); while(!strcmp(ss[i],"****")= =0) { i++: gets(ssEi]); puts(ss[i]); } n=i: max=proe(SS,n); printf("\nmax=%s\n",max); }
编写一个函数,从传入的num个字符中找出最长的一个字符串,并通过形参指针max传回该串地址(用****作为结束输入的标志)。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio.h>
include<stdio.h>
include<string.h>
fun(char (*a) [81], int num, char *max)
{
}
main ()
{
char ss[l0] [81],*ps;
int n, i=0;
clrscr();
prlntf("输入若干个字符串");
gets(ss[i]);
puts(ss[i]);
while(!strcmp(ss[i], "****")==0)
/*用****作为结束输入的标志*/
{
i++;
gets(ss[i]);
puts(ss[i]);
}
n=i;
ps=fun(ss,n,&ps);
print~("\nmax=%s\n",ps);
}
编写一个类,该类的功能是可以根据给定的字符串(字符串的内容可以是中文,也可以是英文,字符串中单词之间可以有空格,也没有空格)和子串,计算出字符串中包含多少个子串。(要求:使用String类的方法。) 程序可以使用下面的框架: import java.util.Scanner; class CountSubString { //【变量声明】 //方法实现 void countSubString(String s, String substring) //s代表整个字符串,substring代表子串 { //【代码】 } } public class CountString { public static void main(String args[]) { Scanner reader=new Scanner(System.in); System.out.println("请输入字符串:"); String s=reader.nextLine(); System.out.println("请输入你要检索的子串:"); String substring=reader.nextLine(); CountSubString a=new CountSubString(); a.countSubString(s, substring); } } 例如,可以输入字符串“I like apple. The apple is decilious. Do you like apple?”和子串“apple”,程序的运行结果应该是检索到3个apple。 再例如,可以输入字符串“Ilikeapple.Theappleisdecilious.Doyoulikeapple?”和子串“apple”,程序的运行结果应该是检索到3个apple。 再例如,可以输入字符串"我喜欢苹果。苹果很美味。你喜欢苹果吗?"和子串"苹果",程序的运行结果应该是检索到3个“苹果”。
编写一个类,该类的功能是可以根据给定的字符串(字符串的内容可以是中文,也可以是英文,字符串中单词之间可以有空格,也可以没有空格)和子串,计算出字符串中包含多少个子串。(要求:使用String类的方法。) 程序可以使用下面的框架: import java.util.Scanner; class CountSubString { //【变量声明】 //方法实现 void countSubString(String s, String substring) //s代表整个字符串,substring代表子串 { //【代码】 } } public class CountString { public static void main(String args[]) { Scanner reader=new Scanner(System.in); System.out.println("请输入字符串:"); String s=reader.nextLine(); System.out.println("请输入你要检索的子串:"); String substring=reader.nextLine(); CountSubString a=new CountSubString(); a.countSubString(s, substring); } } 例如,可以输入字符串“I like apple. The apple is decilious. Do you like apple?”和子串“apple”,程序的运行结果应该是检索到3个apple。 再例如,可以输入字符串“Ilikeapple.Theappleisdecilious.Doyoulikeapple?”和子串“apple”,程序的运行结果应该是检索到3个apple。 再例如,可以输入字符串"我喜欢苹果。苹果很美味。你喜欢苹果吗?"和子串"苹果",程序的运行结果应该是检索到3个“苹果”。
Private Sub Command1_Click()
Dim str As String, s As String, c As String
str = UCase(Text1)
s = ""
c = "Z"
While c >= "A"
If InStr(str, c) = 0 Then
s = 【7】
End If
c = Chr$(Asc(c) 【8】 )
Wend
If s <> "" Then
Text1 = s
End If
End Sub
请补充main函数,该函数的功能是:从键盘输入3个整数,然后找出最大的数并输出。
例如,输入:12,45,43,最大值为45。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<conio.h>
main()
{
int a, b, c, max;
clrscr();
printf("\nlnput three numbers:\n");
scanf("%d,%d,%d",&a,&b,&c);
printf("The three numbers are:%d,
%d,%d\n",a,b,c);
if(a>b)
【 】;
else
【 】;
if(max<c)
【 】;
printf("max=%d\n",max);
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!