题目 传送门 to CF 题目描述 两人轮流执行操作:选一个树上节点,其到根节点的距离至少为 k k k 。选节点上的若干物品,将它移动到 k
1.printf 输出函数,返回的是字符个数 话不多说 直接上代码 int main() { printf("%d", printf("%d", printf("%d", 43))); return 0; } 该程序的打印结果为 2.scanf 输入函数 打印生日,例如输入20130523,输出年份=2013 月份=05 日期=23; int main() { int year = 0;
1、 #include <stdio.h> int main(void) { int i, j, a[6][2], b[2] = {0}, c[6] = {0}; puts("please input the elements of array a."); for(i = 0; i < 6; i++) { for(j = 0; j < 2; j++) { printf(&
c语言中实现矩阵的转置 1、 #include <stdio.h> int main(void) { int i, j, a[4][6], b[6][4]; puts("please input the elements of matrix a."); for(i = 0; i < 4; i++) { for(j = 0; j < 6; j++) { printf(&qu
1、 #include <stdio.h> int main(void) { int i, j, k, a[2][4][3], b[4][3] = {}; for(i = 0; i < 2; i++) { for(j = 0; j < 4; j++) { for(k = 0; k < 3; k++) { printf("
题目链接:https://codeforces.com/contest/32/problem/B #include <iostream> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <climits> #include <cstring> #include <vector> #include &
求3行4列矩阵和4行5列矩阵的乘积。 1、 #include <stdio.h> int main(void) { int i, j, k, a[3][4], b[4][5], c[3][5] = {0}; puts("please input the elements of matrix a."); for(i = 0; i < 3; i++) { for(j = 0; j < 4; j++)
c语言中数组元素的个数。 虽然通过对象式宏修改数组元素个数非常的方便,但是每次都需要对程序进行修改,然后重新编译执行。因此,我们可以定义一个比较大的数组,然后从头开始仅使用其中需要的部分。 1、 #include <stdio.h> #define NUMBER 1000 int main(void) { int i, j, num
用stm32cubemx配置好串口功能之后,想要使用printf函数进行打印输出的话,还需要自己添加一个重定向函数。 1 #ifdef __GNUC__ 2 /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 3 set to 'Yes') calls __io_putchar() */ 4 #define PUT
1、奇数 #include <stdio.h> int main(void) { int i; puts("please input an integer."); printf("i = "); scanf("%d", &i); while(i > 0) { if (i % 2) printf("%d &
#include <stdio.h> #include <stdlib.h> int main() { char ch; /*、putchar() a、 putchar函数的格式:putchar(ch) (其中ch可以是一个字符变量或常量,也可以是一个转义字符) b、putchar函数的作用:向终端输出一个字符。 (1)putchar函数只能用于单个字符的输出,且一次只能输出
#include<stdio.h>#include<math.h>int main(){ int k,j,m; printf("please input a positive number\n"); scanf("%d",&m); /*printf("------------------------\n"); for(k=1;k<=2*m+1;k++) { for(j=1;j<=abs(m+1-k)
感恩感恩! 前期一直没有解决好的IDE串口重定向终于解决了! 参照这位KarmaStone大大的帖子【传送门】 首先还是老规矩,添加头文件 /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include <st
前言 快读快写就是通过一小部分的手动实现(当然要调一些函数),达到快速输入/输出的效果. 快读 思路 通过从头到尾读取字符,记录是否有负号,其余部分用累加器累加(注意不同数位的处理). 代码 template<typename T> inline void read(T &x) { // template的用法详见https://www
今天学习到__int128 类型 这是一个处理大数的很奇妙的方法。 正常来说,unsigned long long 已经是可以定义的最大的类型了,但是如果数据范围超过了2^64 就会爆炸。如果要处理比其大一点又不是那么大的数,就可以使用__int128这个定义。 注意:__int128 并不是所有编译器都可以使用
//习题1.假如我国国民生产总值的年增长率为7%,计算10年后我国国民生产总值与现在相比增长多少百分比。计算公式为 p=(1+r)^n r为年增长率,n为年数,p为与现在相比的倍数。 #include <stdio.h> #include <math.h> //要用到pow函数 int main() { double p,r=0.07,n=10; p=pow(1
#include<stdio.h> int main() { char ch; ch=getchar(); if(ch<'A'||ch>'Z') { printf("输入的不是大写字母,请重新输入!\n"); } ch=ch+32; putchar(ch); putchar('\n'); }
题目链接: https://ac.nowcoder.com/acm/contest/11471/E 题目描述 这一天Kadia与Majiagou在教学弟, 突然提出了一个问题 给你一个超大的数字 让你从中删掉几位 怎么让他最小? 这种签到题不会还有人写不出来吧 不会吧不会吧 输入描述: 第一行输入一个整数N 1<=len(N)<=2×107
#include<stdio.h> void Convert(int n) { int i; if ((i = n / 10) != 0) Convert(i); putchar(n % 10 + '0'); } int main() { int number; printf("输入一个整数: "); scanf("%d", &number); pri
只能判断一次,不能重复判断 # include <stdio.h> int main() { int c, n0 = 0; while((c = getchar())!=EOF) { if(c != ' ') putchar(c); if(c == ' ') { n0++; if(n0 <= 1) putchar(c); } } }
#习题1-9##将输入中的连续多个空格替换为一个并输出```#include <stdio.h> /* Run this program on itself (this file) and the following string " " * will be only one blank long. */ main () { int c; while ((c = getchar()) != EOF) {
class Deque{public: int a[maxn]; int pl=1,pr=0;}Deq;int a[maxn];int n,k;void solve(){ Deq.pl=1;Deq.pr=0; for(int i=1;i<=n;i++){ while(Deq.pr>=Deq.pl&&a[Deq.a[Deq.pr]]<a[i])Deq.pr--;//弹尾 Deq.a[++Deq.pr]=i;//入尾
/* putchar函数,用于输出一个字符 getchar函数,用于输入一个字符A */ #include<stdio.h> int main(void) { char a, b, c; a = getchar(); //获取输入的一个字符 b = getchar(); //如果输入过程中输入回车,将保存成换行符占
题目 点这里看题目。 分析 补习知识: 既然可以求出原串中不同的子串的个数,那么我们同样可以求出含重复子串的个数,同样是\(dp\): \(g(u)\):从\(u\)节点出发含重复的子串的数量。 转移: \[g(u)=|end-p
Stringstream \(stringsteam\)用于进行数据类型转换,\(<sstream>\)库定义了三种类:\(istringstream\)、\(ostringstream\)和\(stringstream\),分别用来进行流的输入、输出和输入输出操作。 接下来举一个栗子,通过这道题我们来介绍下从\(int\)转化为\(string\)的过程 Digits Sequence