当前位置:网站首页>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
边栏推荐
- Pytorch中transforms的用法整理
- Varnish foundation overview 4
- Cookie加密15 登录加密
- C language final without failing (Part 1)
- 3-6sql injection website instance step 5: break through the background to obtain web administrator permissions
- 存储引擎分析
- Varnish 基础概览2
- What should be paid attention to in the design and production of the Urban Planning Museum
- Sentinel source code analysis Part 8 - core process - sphu Entry current limiting execution
- 81. search rotation sort array II
猜你喜欢
随机推荐
What to remember about the penalty for deduction of points in Item 1
3-6sql injection website instance step 5: break through the background to obtain web administrator permissions
对深度网络模型量化工作的总结
Kubernetes 核心对象概览详解
Pytroch Learning Notes 6: NN network layer convolution layer
c语言选择,循环概述
The first technology podcast month will begin soon
【机器学习Q&A】准确率、精确率、召回率、ROC和AUC
Varnish 基础概览6
Ansible ad-hoc temporary command
Varnish 基础概览8
C语言 继续(3n+1)猜想
Mysql 监控1
Is the course of digging money reliable and safe to open an account?
【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类
Varnish foundation overview 5
工具与生活服务
Tetris game based on STM32F103
Sklearn notes: make_ Blobs generate clustering data
Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases