当前位置:网站首页>[pointer] find the largest string
[pointer] find the largest string
2022-07-06 14:36:00 【|Light|】
requirement
Make up a function , Find the largest string .( Use a pointer to achieve )
Code
#include<string.h>
#include<stdlib.h>
/* * This function is used to find n The largest of the strings * a Is a two-dimensional character array , Each line holds a string ,n Is the number of strings with lookup */
char * find_max_string(char a[][300],int n)
{
char *pmax;
int i, j = 0, k;
for (i = 0; i < n; i++)
{
k = strcmp(a[j],a[i]);
if (k < 0)
{
j = i;
}
}
pmax = &a[j-1][300];
return pmax;
}
main function
int main()
{
char a[10][300]={
0},*p;
int n=0;
while(gets(a[n])!=NULL){
n++;
}
p=find_max_string(a,n);
puts(p);
return 0;
}
test
Test input
I love China
I Love China
I have dream
Output
I love China
边栏推荐
- 指针 --按字符串相反次序输出其中的所有字符
- Matplotlib绘图快速入门
- JDBC 的四种连接方式 直接上代码
- Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
- Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
- Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
- How does SQLite count the data that meets another condition under the data that has been classified once
- AQS details
- The difference between layer 3 switch and router
- Internet Management (Information Collection)
猜你喜欢
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
5 minutes to master machine learning iris logical regression classification
On the idea of vulnerability discovery
数字电路基础(三)编码器和译码器
sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现
Intranet information collection of Intranet penetration (5)
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
线程的实现方式总结
内网渗透之内网信息收集(二)
Attack and defense world misc practice area (GIF lift table ext3)
随机推荐
Function: find the maximum common divisor and the minimum common multiple of two positive numbers
What language should I learn from zero foundation. Suggestions
数据库多表链接的查询方式
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Mathematical modeling idea of 2022 central China Cup
Solutions to common problems in database development such as MySQL
Chain team implementation (C language)
Detailed explanation of network foundation routing
“人生若只如初见”——RISC-V
Uibutton status exploration and customization
Attack and defense world misc practice area (GIF lift table ext3)
Proceedingjoinpoint API use
XSS unexpected event
Intel oneapi - opening a new era of heterogeneity
flask实现强制登陆
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
函数:计算字符串中大写字母的个数
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence