printf

第三届CCF软件能力认证

丶灬走出姿态 提交于 2020-03-29 09:13:25
1.门禁系统 问题描述   涛涛最近要负责图书馆的管理工作,需要记录下每天读者的到访情况。每位读者有一个编号,每条记录用读者的编号来表示。给出读者的来访记录,请问每一条记录中的读者是第几次出现。 输入格式   输入的第一行包含一个整数n,表示涛涛的记录条数。   第二行包含n个整数,依次表示涛涛的记录中每位读者的编号。 输出格式   输出一行,包含n个整数,由空格分隔,依次表示每条记录中的读者编号是第几次出现。 样例输入 5 1 2 1 1 3 样例输出 1 1 2 3 1 评测用例规模与约定   1≤n≤1,000,读者的编号为不超过n的正整数。 1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <algorithm> 5 # include <cmath> 6 # define LL long long 7 using namespace std ; 8 9 int a[1010] ; 10 11 int main () 12 { 13 //freopen("in.txt","r",stdin) ; 14 int n ; 15 scanf("%d" , &n) ; 16 int i , x ; 17 for (i = 1 ; i <= n-1 ; i++) 18 { 19

C语言字符串函数大全

天大地大妈咪最大 提交于 2020-03-29 03:54:47
C语言字符串函数大全 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: 1 #include <stdio.h> 2 3 #include <string.h> 4 5 6 7 int main(void) 8 9 { 10 11 char string[10]; 12 13 char *str1 = "abcdefghi"; 14 15 16 17 stpcpy(string, str1); 18 19 printf("%s\n", string); 20 21 return 0; 22 23 } 函数名: strcat 功 能: 字符串拼接函数 用 法: char *strcat(char *destin, char *source); 程序例: 1 #include <string.h> 2 3 #include <stdio.h> 4 5 6 7 int main(void) 8 9 { 10 11 char destination[25]; 12 13 char *blank = " ", *c = "C++", *Borland = "Borland"; 14 15 16 17 strcpy(destination, Borland); 18 19

c语言字符函数

送分小仙女□ 提交于 2020-03-29 03:54:04
函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include <stdio.h> #include <string.h> int main(void) { char string[10]; char *str1 = "abcdefghi"; stpcpy(string, str1); printf("%sn", string); return 0; } 函数名: strcat 功 能: 字符串拼接函数 用 法: char *strcat(char *destin, char *source); 程序例: #include <string.h> #include <stdio.h> int main(void) { char destination[25]; char *blank = " ", *c = "C++", *Borland = "Borland"; strcpy(destination, Borland); strcat(destination, blank); strcat(destination, c); printf("%sn", destination); return 0; } 函数名: strchr 功 能:

string.h文件中函数的详细用法

删除回忆录丶 提交于 2020-03-29 03:48:10
 下面为string.h文件中函数的详细用法,附加实例: 1、strcpy   函数名: stpcpy   功 能: 拷贝一个字符串到另一个   用 法: char *stpcpy(char *destin, char *source);   程序例:   #include <stdio.h>   #include <string.h>   int main(void)   {   char string[10];   char *str1 = "abcdefghi";   stpcpy(string, str1);   printf("%s\n", string);   return 0;   } 2、strcat   函数名: strcat   功 能: 字符串拼接函数   用 法: char *strcat(char *destin, char *source);   程序例:   #include <string.h>   #include <stdio.h>   int main(void)   {   char destination[25];   char *blank = " ", *c = "C++", *Borland = "Borland";   strcpy(destination, Borland);   strcat(destination, blank

codeforces-1327C-Game with Chips

做~自己de王妃 提交于 2020-03-29 00:31:25
codeforces-1327C-Game with Chips 传送门: https://codeforces.com/contest/1327/problem/C 题意:有一个n*m的电路板,给你k个当前点和k个目标点,每次可以进行上下左右的移动(每次移动所有的当前点都动)(如果芯片位于板壁的旁边,并且Petya选择的动作将其移向壁,则芯片将保持在其当前位置),使得所有的当前点都至少经过目标点一次,移动范围不超过2*n*m,应该怎么走 每次移动所有点都跟着动是不是很懵逼?还要经过给出的目标点?看移动范围呀,2*n*m呀,当前点和目标点屁用没有,把所有点挤到一个角,蛇形跑一边就完了,移动次数n*m+n+m-3,散了吧散了吧,这题太骚了 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 const int maxn=1e6+10; 5 const int mod=1e9+7; 6 const int inf=0x3f3f3f3f; 7 int mp[209][209]; 8 int main() 9 { 10 int t,n,m,k,x,y; 11 12 scanf("%d%d%d",&n,&m,&k); 13 for(int i=1;i<=2*k;i++) 14 { 15 scanf

C语言实验(三)

て烟熏妆下的殇ゞ 提交于 2020-03-28 17:45:28
第四章分支结构实验 实验项目: 第四章实验设计 实验项目: 4.3.1 if语句的应用 ,4.3.2 switch case的应用 ,4.3.3 switch case嵌套if语句的应用 ,4.3.4 switch case结构嵌套的运用 ,4.3.5 分析程序, 计算器。 姓名:蔡鹏 实验地点:家中  实验时间:2020.03.25 实验目的与要求: 1、 掌握各种形式的if语句语法和使用方法 2、掌握使用算术运算符和运算规则,switch case语句的使用方法 3、掌握switch case结构的嵌套使用,break语句的用法 4、熟练掌握C语言的运算符,即运算符的优先级和结合性、运算规则、运算对象类型等。 实验内容: 1 ·实验练习:4.3.1 if语句的应用 (1)问题的简单描述:读入3个表示箱子长、宽、高的整数值,判断并输出是正方体还是长方体。 (2)实验代码: #include<stdio.h> int main() { int l,w,h; printf("请输入箱子的长、宽、高:\n"); scanf("%d,%d,%d",&l,&w,&h); if(l==w&&w==h&&l==h) printf("该箱子是正方体。\n"); else printf("该箱子是长方体。\n"); return 0; } (3)问题分析:比较长,宽,高用 l==w&&w==h&

C程序第四章实验报告

我的未来我决定 提交于 2020-03-28 17:18:22
C程序设计实验报告 实验项目: 4.3.1:if语句的应用 4.3.2:switch-case的应用 4.3.3:switch-case嵌套if语句的应用 4.3.4:switch-case结构嵌套的应用 4.3.5:分析程序 项目实训:计算器的实现 姓名:钟宗浩 实验地点:家 实验时间:2020.3.26 一、实验目的与要求 1.掌握C语言逻辑值的表示方法(0代表“假”,1代表“真”) 2.学会正确地使用关系表达式和逻辑表达式 3.掌握各种形式的if语句语法和使用方法。if语句中if和else的匹配关系,以及if语句的嵌套。 4.熟练掌握switch语句的语法和使用方法,注意在switch语句中break语句的用法及switch语句的嵌套 二、实验内容 1、实验练习:if语句的应用 1问题的简单描述:读人3个表示箱子长、宽、高的整数值,判断并输出该箱子是正方体还是长方体。 2实验代码: #include<stdio.h> main() { float a,b,c; printf("输入长宽高对应长度"); scanf("%f%f%f",&a,&b,&c); if(a==b&&b==c) printf("该箱子是正方体。\n"); else printf("该箱子为长方体。\n"); } 3问题分析:此处应该注意赋值与数值相等的运算符的区别,判断长、宽、高是否相等。 2、实验练习

【实验6】数组1

流过昼夜 提交于 2020-03-28 05:39:26
1、输入n个整数,将它们存入数组a中。输出最大值和它所对应的下标。 #include<stdio.h> int main() { int i,index,n; int a[10]; printf("Enter n:");/*提示输入 n*/ scanf("%d",&n); printf("Enter %d integers:",n);/*提示输入n个数*/ for(i=0;i<n;i++) scanf("%d",&a[i]); index=0; /*假设下标为0的元素最小*/ for(i=1;i<n;i++) if(a[i]<a[index])/*如果a[i]比假设的最小值还小*/ index=i;/*再假设a[i]是新的最小值,即下标为i的元素最小*/ /*输出最小值和下标*/ printf("min is %d\tsub is %d\n",a[index],index); return 0; } 2、输入n个整数,存入数组a中,分别按正序和逆序输出这些数; #include<stdio.h> int main(void) { int i,index,k,n,temp; int a[10];/*定义1个数组啊,它有10个元素*/ printf("Enter n:");/*提示输入n*/ scanf("%d",&n); printf("Enter %d integers:",n);

实验6 数组1

…衆ロ難τιáo~ 提交于 2020-03-28 05:39:10
1. 输入n个整数,将它们存入数组a中。输出最大值和它所对应的下标 /*输入n个整数,将它们存入数组a中。输出最大值和它所对应的下标*/ #include<stdio.h> int main(void) { int i,index,n; int a[10]; /*定义1个数组a,它有10个整型元素*/ printf("Enter n:"); /*提示输入n*/ scanf("%d",&n); printf("Enter %d integers:",n); /*提示输入n个数*/ for(i=0;i<n;i++) scanf("%d",&a[i]); /*将输入的数依次赋给数组a的n个元素a[0]~a[n-1]*/ /*找最小值a[index]*/ index=0; /*假设a[0]是最大值,即下标为0的元素最大*/ for(i=1;i<n;i++) if(a[i]>a[index]) /*如果a[i]比假设的最大值还大*/ index=i; /*再假设a[i]是新的最大值,即下标为i的元素最小*/ printf("max is %d\tsub is %d\n",a[index],index); /*输出最大值和对应的下标*/ return 0; } 2、输入n个整数,存入数组a中,分别按正序和逆序输出这些数; /*输入n个整数,存入数组a中,分别按正序和逆序输出这些数;*/

Petrozavodsk Summer-2016. Ural FU Dandelion Contest

被刻印的时光 ゝ 提交于 2020-03-28 05:16:36
A. Square Function 留坑。 B. Guess by Remainder 询问$lcm(1,2,3,...,n)-1$即可一步猜出数。 计算$lcm$采用分治FFT即可,时间复杂度$O(n\log^2n)$。 C. Subtract if Greater! 对于每个修改操作,$[1,x]$的数无需修改,$[x+1,2x]$的数会减小至少一半,暴力修改即可,$[2x+1,inf]$的数减小之后排名不变,故可以在平衡树上打标记实现。 时间复杂度$O(n\log^2n+m\log n)$。 #include<cstdio> #include<algorithm> const int N=100010,inf=~0U>>1; int n,m,i,op,k,a[N],val[N],tag[N],size[N],son[N][2],f[N],tot,root; inline void read(int&a){char c;while(!(((c=getchar())>='0')&&(c<='9')));a=c-'0';while(((c=getchar())>='0')&&(c<='9'))(a*=10)+=c-'0';} inline void add1(int x,int p){ if(!x)return; val[x]+=p; tag[x]+=p; } inline