当前位置:网站首页>[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
边栏推荐
- JVM memory model concept
- . Net6: develop modern 3D industrial software based on WPF (2)
- 《统计学》第八版贾俊平第四章总结及课后习题答案
- [issue 18] share a Netease go experience
- An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
- Proceedingjoinpoint API use
- High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
- Matplotlib绘图快速入门
- 【指针】使用插入排序法将n个数从小到大进行排列
- Interview Essentials: what is the mysterious framework asking?
猜你喜欢
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
Solutions to common problems in database development such as MySQL
Keil5-MDK的格式化代码工具及添加快捷方式
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
Intel oneapi - opening a new era of heterogeneity
An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
四元数---基本概念(转载)
关于交换a和b的值的四种方法
随机推荐
Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
Binary search tree concept
Keil5-MDK的格式化代码工具及添加快捷方式
Sentinel overall workflow
Intel oneapi - opening a new era of heterogeneity
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
Pointers: maximum, minimum, and average
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
Low income from doing we media? 90% of people make mistakes in these three points
【指针】求解最后留下的人
Network layer - simple ARP disconnection
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
数字电路基础(二)逻辑代数
The most popular colloquial system explains the base of numbers
Database monitoring SQL execution
. Net6: develop modern 3D industrial software based on WPF (2)
刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
《統計學》第八版賈俊平第七章知識點總結及課後習題答案
《统计学》第八版贾俊平第四章总结及课后习题答案