C/C++输入函数 1.**scanf() ** #include 我们从键盘上读取的信息都是字符类型(char),而将它们转换成int类型或者double类型,就是scanf()函数的工作 scanf()函数使用规则: 如果用scanf()读入基本变量类型的值,在变量名前加一个& 如果用scanf ...
分类:
编程语言 时间:
2020-06-26 22:39:37
阅读次数:
72
#「状压DP」「暴力搜索」排列 #题目描述: ###题目描述 给一个数字串 s 和正整数 d, 统计 sss 有多少种不同的排列能被 d 整除(可以有前导 0)。例如 123434 有 90 种排列能被 2 整除,其中末位为 2 的有 30 种,末位为 4 的有 60 种。 ###输入格式 输入第一 ...
分类:
其他好文 时间:
2020-06-26 20:29:40
阅读次数:
49
给出n-1 个ai,i = 2 ~ n ,可以认为a1 = 1~n-1 问对每个i,输出最后y的大小 。 其中操作循环为 1. x+a[x] , y+ a[x] 2. x- a[x] , y+a[x] 。 退出条件为x>n 或 x<0 明显是记忆化搜素, 需要记忆操作的方向 。可以借助y每次总是+a ...
分类:
其他好文 时间:
2020-06-26 14:41:54
阅读次数:
43
/*1.三目运算符的使用 2.日期:2020年6月25日12:04:48 3.环境:vs2019*/ #include<stdio.h> int main() { //定义变量 int a = 0; int b = 0; int c = 0; int max = 0; scanf_s("%d%d%d ...
分类:
其他好文 时间:
2020-06-25 16:03:17
阅读次数:
55
1 #include<stdio.h> 2 3 int main(){ 4 int n = 0; 5 int num = 0; 6 //printf("请输入一个不超过1000的正整数:"); 7 scanf("%d", &num); 8 while(num != 1){ 9 if(num%2 == ...
分类:
其他好文 时间:
2020-06-25 09:17:48
阅读次数:
64
问题描述 : 输入若干(不超过100个)非负整数,创建一个不带头结点的单向链表。在输入一个位置index,从链表中删除第index个结点,输出结果链表。 请编写deleteNode函数,完成删除操作。deleteNode函数的原型如下: struct student *deleteNode(stru ...
分类:
其他好文 时间:
2020-06-24 23:31:41
阅读次数:
65
#include<iostream> #include<cstdio> #include<queue> using namespace std; int dis[200001],head[200001]; int n,m,a,b,c,s,cnt; bool vis[200001]; struct e ...
分类:
其他好文 时间:
2020-06-23 21:35:40
阅读次数:
59
1、使用gets() char *arr; arr = malloc(50 * sizeof(char)); gets(arr); 2、使用scanf() scanf("%[^\n]", arr); //遇到‘\n’结束读取 3、使用getchar() int k = 0; while((arr[k ...
分类:
编程语言 时间:
2020-06-23 15:10:11
阅读次数:
63
题目传送门:AtCoder Grand Contest 005。 A - STring 括号匹配。 #include <cstdio> const int MN = 200005; char s[MN], t[MN]; int tp; int main() { scanf("%s", s + 1); ...
分类:
其他好文 时间:
2020-06-23 00:47:22
阅读次数:
71
这个是C语言当中常见的错误,意思是 对于输入的scanf参数的内容,没有进行类型判断,所以才会产生这个问题. 解决方法: 1、添加if判断方式 1 if(scanf("%d",&a)==1){ 2 // 成功继续执行其他代码 3 } View Code 2、其它类型判断方式扩展 1 if(scanf ...
分类:
其他好文 时间:
2020-06-22 01:57:11
阅读次数:
146