当前位置:网站首页>C language irony
C language irony
2022-06-30 01:31:00 【Martin の Blog】

Algorithm design ideas
- Use fget Method to get the input string
- Judge whether there is carriage return in the string , If there is a carriage return, directly set the character to the end of the positioning pointer , Output to prevent carriage return
- Determine the space in the string , If the space is not empty , Then start printing the characters after the space , And set the current pointer to the tail pointer
- Be careful strrchr The function returns the last character
- Print the remaining characters , That is, the content of the first character
Code
#include <stdio.h>
#include <string.h>
int main(){
char s[100];
char *p;
fgets(s, 100, stdin);
if((p=strrchr(s, '\n')) != NULL){
*p = '\0';
}
while((p=strrchr(s, ' ')) != NULL){
printf("%s ", p+1);
*p = '\0';
}
printf("%s", s);
return 0;
}
Running results 
边栏推荐
- [mrctf2020]ezpop-1 | PHP serialization
- Cookie加密13
- 第八届“互联网+”大赛 | 云原生赛道邀你来挑战
- Pytorch中transforms的用法整理
- Embedded test template
- I, 33 years old, ByteDance test development, unveiled the real income of Beijing "test post"
- The Web3 era is coming? Inventory of five Web3 representative projects | footprint analytics
- 挖财的课程靠谱吗,让开户安全吗?
- Sentinel source code analysis Part 6 - sentinel adapter module Chapter 4 zuul2 gateway
- Pytorch 修改hook源码 获取Per-Layer输出参数(带layer name)
猜你喜欢

What should be paid attention to in the design and production of the Urban Planning Museum

Tetris game based on STM32F103

Cookie encryption 11

C语言 素数对猜想

Preliminary understanding of NVIDIA Jetson nano

Precautions for postoperative fundus hemorrhage / / must see every day

cookie加密9

Kubernetes core object overview details

画画水族馆的应用特色及功能

Ansible ad-hoc temporary command
随机推荐
首届·技术播客月开播在即
js内容混淆,返回内容加密
OpenCV和Image之间的转换(亲测有效)
MySQL monitoring 3
城市规划馆在设计制作上需要注意什么
【推荐系统】基于用户的协同过滤简明原理与代码实现
Mysql 监控6
Stringredistemplate disconnects and the value disappears
Kubernetes core object overview details
【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类
Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases
Ansible ad-hoc temporary command
cookie加密11
Varnish 基础概览3
Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object
Varnish 基础概览10
Embedded test template
Is the course of digging money reliable and safe to open an account?
What should be paid attention to in the design and production of the Urban Planning Museum
Interview summary