codeforces 41A-C语言解题报告

41A题目网址

题目解析

1.输入一个字符串,如果第二行是倒序输入这个字符串的,就输出YES,否则输出NO

举例:
输入:
abb
aba
输出:
NO

2.倒序输出时,使用int j=strlen(t)-1;,因为strlen()是计算字符个数,而字符串是从0开始,最后一位是字符串长度减一

3.在接收第二个字符串输入时,因为有enter键,所以使用getchar()去接收
即:
scanf("%s",s);
getchar();
scanf("%s",t);

代码

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{  char s[100]={'0'};char t[100]={'0'};scanf("%s",s);getchar();scanf("%s",t);int j=strlen(t)-1,flag=0;for(int i=0;i<strlen(s);i++){if(s[i]==t[j--]){flag=1;}else {flag=0;break;}}if(flag){printf("YES");}else{printf("NO");}getchar();system("pause");return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/446642.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linux查看文件的首个字母 文件属性字段

-rw-r–r– 1 root root 762 07-29 18:19 exit文件属性字段总共有10个字母组成&#xff1b;第一个字符代表文件的类型。 文件属性字段 字母“-”表示该文件是一个普通文件字母“d”表示该文件是一个目录&#xff0c;字母”d”&#xff0c;是dirtectory(目录)的缩写&#xff1b…

英语口语-文章朗读Week10 Wednesday

英语文章 Everyone needs sleep for survival, but how much? It is said that eight hours of sleep is fundamental to a healthy person. But today, many people are sacrificing their sleep time。 Modern people have so many alternatives: cell phones, PCs, TVs, g…

嵌入式Linux多任务编程 进程 管道 命名管道

进程 进程是一个可并发执行的具有独立功能的程序关于某个数据集合的一次执行过程&#xff0c;也是操作系统执行资源分配和保护的基本单位。程序的一次执行就是一个进程一个程序可以派生多个进程多个不同程序运行的时候&#xff0c;也会有多个相对应的进程与其相互对应进程是动…

2000年考研英语阅读理解文章五

文章详细解析网址 知识点 ----单词 vitality n生命力 hypocritical adj伪善的 pushing adj有进取心的 acquisitive adj渴望获得的,贪得无厌的 confess v供认,坦白 vulgar adj粗俗的 spectacle n场面,奇观 participatory adj供分享的 democracy n民主,民主制,民主国家 stir v搅…

英语口语-文章朗读Week10 Thursday

英语文章 There are many customs and traditions in Chinese civilization. Here, we will talk about the development of the way people greet each other: In ancient times, people had to kneel to those who were superior to them. This custom remained until the …

Linux进程之间通信 信号

2) SIGINT 程序终止(interrupt)信号, 在用户键入INTR字符(通常是Ctrl-C)时发出&#xff0c;用于通知前台进程组终止进程。 3) SIGQUIT 和SIGINT类似, 但由QUIT字符(通常是Ctrl-\)来控制. 进程在因收到SIGQUIT退出时会产生core文件, 在这个意义上类似于一个程序错误信号。 15)…

c++面向对象高级编程 学习一 不带指针的类

复数类 complex 是一个不带指针的类&#xff0c;其声明如下&#xff1a; class complex { public: complex(double r0,double i0):re(r),im(i){} complex& operator (const complex&); double real()const{return re;} double imag()const{return im;}private: double…

codeforces 734A-C语言解题报告

734A题目网址 题目解析 1.输入n个结果,再输入每一个结果(A或D),统计A和D的数目,A>D,则输出Anton,A<D,输出Danik,AD,输出Friendship 代码 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int n0,A0…

Linux进程之间通信 消息队列

使用命令 ipcs -q 查看对应的消息队列代码 文件接收者 #include <sys/types.h> #include <stdio.h> #include <unistd.h> #include <string> #include <signal.h> #include <wait.h> #include <sys/msg.h> #include <cstring&g…

c++面向对象高级编程 学习二 带指针的类

带指针的类&#xff0c;必须要自己写拷贝构造和赋值构造 拷贝构造&#xff1a;参数和类的类型一样的构造函数 赋值构造&#xff1a;重写操作符&#xff0c;且其参数和类的类型一样 class String { public: String(const char* cstr 0); String(const String& str); Strin…

英语口语 week11 Tuesday

英语文章 It was a cold and gloomy winter afternoon, people with their chilled hands tucked into their pockets or hidden in their sleeves. Fred was in a depressed mood, just like the weather,for he failed to get any award in the debate competition When he …

codeforces 271A-C语言解题报告

271A题目网址 题目解析 1.输入一个年份,求这个年份之后的每一个数字都各不相同的年份 举例: 输入: 2013 输出: 2014 2.求年份(四位数)的每一位数,再把这些数逐个比较 四位数求: 千位:n/1000 百位:n%1000/100 十位:n%100/10 个位:n%10/1; 代码 #include<stdio.h> #in…

进程之间通信 共享内存

命令 ipcs 命令查看共享内存、消息队列、管道等相关信息ipcs -m 查看共享内存的信息代码 创建共享内存共享内存 关联 进程分离共享内存删除共享内存 #include <sys/shm.h> #include <iostream>#define BUF_SIZE 1024int main() {int share_id 0;//创建共享内存i…

c++面向对象高级编程 学习三 堆、栈和内存泄漏

栈&#xff0c;是存在于某作用域的一块内存空间。在函数体内声明的任何变量&#xff0c;其所使用的内存空间均来自于栈。 堆&#xff0c;是指由操作系统提供的一块global内存空间&#xff0c;程序可动态分配获得若干内存空间块。 new操作符生成的对象所占用的内存空间即是从堆中…

clion编写C++ 使用多线程时候,CMakeLists.txt书写,引用-pthread

添加如下一行 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") 具体的例子 cmake_minimum_required(VERSION 3.17) project(mutex_learn)set(CMAKE_CXX_STANDARD 14)set(BOOST_ROOT "/usr/local/include/boost") #添加头文件搜索路径 include_direc…

codeforces 677A-C语言解题报告

677A题目网址 题目解析 1.输入n个数字,如果输入的数字比h大,就加2,如果小于等于h,就加1 举例: 输入: 3 7 4 5 14 输出: 4 代码 #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int n0,h0,count0;int nu…

c++面向对象高级编程 学习四 静态、类模板、函数模板

静态static&#xff1a;静态数据和静态函数&#xff0c;在内存中只有一份&#xff0c;不会随着创建对象的数目的增加而增加 static数据&#xff1a;比如银行的account类中&#xff0c;账户名是普通数据&#xff0c;100个对象会有100个账户名&#xff0c;但利率都是相同的&#…

线程的编程

完整代码 #include <sys/shm.h> #include <iostream> #include <unistd.h> #include <pthread.h>void * child1(void *arg){pthread_t tid pthread_self();printf("1 thread %lu \n",tid);}int main(int argc,char* argv[]) {int result{…

英语口语 week11 Friday

英语文章 I very much like simplicity in life. For me, college is far more than a place to improve my intellectual abilities Every weekend, I usually have a walk along the way to the front gate of Mount Qingcheng, enjoying the intense aromas of flowers on …