codeforces 271A-C语言解题报告

271A题目网址

题目解析

1.输入一个年份,求这个年份之后的每一个数字都各不相同的年份
举例:
输入:
2013
输出:
2014

2.求年份(四位数)的每一位数,再把这些数逐个比较
四位数求:
千位:n/1000
百位:n%1000/100
十位:n%100/10
个位:n%10/1;

代码

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{ int year=0,result=0;int a=0,b=0,c=0,d=0;scanf("%d",&year);for(int i=1;i<=9000;i++){result=year+i;a=result/1000;//千位b=result%1000/100;//百位c=result%100/10;//十位d=result%10/1;//个位if(a!=b&&a!=c&&a!=d&&b!=c&&b!=d&&c!=d){printf("%d",result);break;}}getchar();system("pause");return 0;
}

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

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

相关文章

进程之间通信 共享内存

命令 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 …

c++面向对象高级编程 学习五 组合、委托与继承

组合 composition 表示has a queue类中有一个deque容器&#xff0c;这种关系叫做 组合 queue中的六个函数都是调用c的函数完成的 template <class T> class queue { ... protected: deque<T> c; // 底層容器 public: // 以下完全利用 c 的操作函數完成 bool empt…

C++四种类型转换运算符:static_cast、dynamic_cast、const_cast和reinterpret_cast

参考链接 C四种类型转换运算符&#xff1a;static_cast、dynamic_cast、const_cast和reinterpret_cast

英语口语 week12 WednesDay

英语文章 Chengdu, a city with a long history, has always enjoyed the reputation as " The Land of Abundance" . It has been noted as one of the most livable cities in China, partly resulting from its favorable natural conditions and wealthy produc…

c++面向对象高级编程 学习六 虚函数

虚函数&#xff1a;在成员函数前面加上virtual&#xff0c;函数就变成了虚函数 继承函数&#xff1a;子类可以调用父类的函数&#xff0c;叫做继承了函数&#xff0c;即函数的调用权 三种函数&#xff1a; non-virtual 函数&#xff1a; 你不希望 derived class 重新定义 (ov…

C++ 数据结构 线性链表

#pragma once 减少头文件组合&#xff0c;降低编译出错的概率作用等效于 #ifndef FUNC_H #define FUNC_H代码主体#endif 线性表的定义 排队问题 简单的线性表 (物理 或者逻辑结构)1&#xff0c;数组2&#xff0c;链表线性表相关操作&#xff1a;1&#xff0c;线性表初始化2&a…

英语口语 week12 Thursday

英语文章 As the pace of life quickens with technological advancements, people are occupied by all kinds of trivial matters. They seem forever on the go. There’s no difficulty in imagining that the hustle and bustle of everyday life can make us lose focus…

H.264/AVC视频编解码技术详解 第一章 视频信息与压缩编码

H.264/AVC视频编解码技术详解系列笔记 是对 H.264/AVC视频编解码技术详解 课程的学习 文章目录人与世界的交互视频信号的表示方法视频压缩编码视频信息为什么可以被压缩&#xff1f;视频压缩编码的分类&#xff1a;视频压缩编码的基本技术人与世界的交互 从远古时代开始&#…

英语口语 week13 Monday

英语文章 Competitions between businesses can be very aggressive in contemporary society. However, the competition for talented personnel is thought to be the key to business competition. Wise employers consider their employees as the company’s core asset…

文件系统的由来

启蒙篇 文件的由来 磁盘上保存的是一对十六进制的数据&#xff0c;如何切分数据形成不同的文件&#xff0c;也就是如何确定一个文件的起始和终止位置&#xff1f;将相关数据打包在一起形成一个文件&#xff0c;比如从什么位置开始到什么位置结束&#xff0c;是一张图片、一段…

c++面向对象高级编程 学习七 转换函数

转换函数&#xff1a;对象A和对象B之间的互相转换。 class Fraction { public:Fraction(int num,int den1):m_numerator(num),m_denominator(den){}operator double()const{return (double)(m_numerator/m_denominator);} private:int m_numerator; //分子int m_denominator;/…

英语口语 week13 Wednesday

英语文章 Despite his extraordinary success in writing fairy tales,Hans Christian Andersen preferred to living in a way of simplicity and frugality. He often wore an old hat when he went out. One day, a well-dressed man stopped Andersen on the street, inte…

数据结构 队列

队列 代码 #include <stdio.h> #include <stdlib.h>/************************************************************************/ /* 队列结构要素&#xff1a;队列容量 内存指针 元素个数 队列头 对列尾*/ /********************************************…

c++面向对象高级编程 学习八 non-explicit-one-argement-ctor

explicit&#xff08;显式的&#xff09;&#xff1a;作用是"禁止单参数构造函数"被用于自动类型转换 non-explicit: class Fraction { public:Fraction(int num,int den1):m_numerator(num),m_denominator(den){}Fraction operator (const Fraction& f){retur…