PTA天梯赛
hj_cheng29
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1008 数组元素循环右移问题 (20分)测试点1,2
#include <stdio.h>int main(){ int n,m,i; scanf("%d %d",&n,&m); int a[n]; for(i=0;i<n;i++){ scanf("%d",&a[i]); } for(i=0;i<n;i++){ if(i==0) printf("%d",a[(i+2*n-m)%n]); //测试点1、2.原创 2020-05-13 11:09:38 · 604 阅读 · 0 评论 -
1049 数列的片段和 (20分)
首先,直接暴力算法,但是最后两个测试点超时了#include <stdio.h>//int main(){// int n,i,j,k=0,num;// scanf("%d",&n);// double a[n];// double count = 0;// for(i=0;i<n;i++){// scanf("%lf",&a[i]);// }// for(i=0;i<n;i++){// num = i;// .原创 2020-05-11 16:43:58 · 158 阅读 · 0 评论 -
1042 字符统计 (20分)测试点一分析
测试点一分析:只有一个字母,所以maxEn初始要设置成最大的字母即是’z’,不要设成第一个字符,因为很有可能第一个字符不是字母/*测试点一:只有一个字母,所以maxEn初始要设置成最大的字母即是'z',不要设成第一个字符,因为很有可能第一个字符不是字母*/#include <stdio.h>int main(){ char str[1001]; int set[256]={0}; gets(str); int i; for(i=0;str[i]!='\0';i++.原创 2020-05-09 11:18:00 · 429 阅读 · 0 评论 -
1033 旧键盘打字 (20分)
#include <stdio.h>int main(){ char bad[100001]; char realbad[100001]; char origin[100001]; gets(bad); gets(origin); int i,j=0,flag = 0;//flag标志上档键有没有坏 for(i=0;bad[i]!='\0';i++){...原创 2020-05-07 10:37:46 · 179 阅读 · 0 评论 -
1001 A+B Format (20分)
#include <stdio.h>#include <stdlib.h>int f = 0,count = 0;char str[13];void printN(int n);int main(){ int a,b; scanf("%d %d",&a,&b); int res = a+b; if(res==0){ pr...原创 2020-05-06 15:17:36 · 246 阅读 · 0 评论 -
(C语言复习)1029 旧键盘 (20分) 测试点4分析
第一次的代码测试点4报错,后来才发现while(originStr[i]!=’\0’&&realStr[j]!=’\0’){ //这个判断条件就很可能导致,最后一个测试点不通过,因为实际输入的文字串结束而应该输入的文字串未结束时,应该输入的文字串后面可能还会有一些坏键,由于循环已经退出,它们将不能输出,从而导致错误。#include <stdio.h>int ...原创 2020-05-06 11:29:21 · 1487 阅读 · 1 评论 -
1024 科学计数法 (20分)
本题用字符串的方式求解,往后往前移动小数点的时候稍微有点绕,边测试边修改代码及即可AC代码#include <stdio.h>int main(){ char str[10001]; int flag = 0;//标志位 gets(str); if(str[0]=='-') printf("-"); int i=0,j; while(str[...原创 2020-05-05 11:58:06 · 202 阅读 · 0 评论 -
(进制转化考前必看)1022 D进制的A+B (20分)
第一遍就AC了,递归的思想:1,先找出口,这里的出口就是前两个if2,从宏观上来看,每一步要做的是什么。#include <stdio.h>void printHex(int num,int hex);int main(){ int A,B,hex; scanf("%d %d %d",&A,&B,&hex); int res = A+...原创 2020-05-05 09:50:49 · 148 阅读 · 0 评论 -
复习1017 A除以B (20分)测试点1
测试点1:天坑,如果被除数只有一位并且还没有除数大,那么就应该输出0 被除数,例如: 5 7,输出 0 5(不是0 7哦)!!!!!#include <stdio.h>#include <string.h>int main(){ char a[1001]; int res[1001]; int top = 0; int b,i,temp,c=0;...原创 2020-05-01 20:13:50 · 678 阅读 · 2 评论 -
L2-015 互评成绩 (25分)
/*思路: 一行一行的判断, 输入一行就排序,去掉两端,求平均 吧平均的存入avr[N]中,再对AVR排序,输出最后M个*/#include <stdio.h>#include <stdlib.h>int cmp(void const *a,void const *b);int cmp2(void const *a,void const *b)...原创 2020-04-30 11:12:02 · 455 阅读 · 0 评论 -
L2-011 玩转二叉树 (25分)
#include <stdio.h>#include <stdlib.h>typedef struct node{ int data; struct node *left; struct node *right;}*BiTree;BiTree createTreeByInAndPreOrder(int *In,int *Pre,int ...原创 2020-04-26 10:44:16 · 328 阅读 · 0 评论 -
L2-009 抢红包 (25分)
本题要注意的点是:如果收入金额有并列,则按抢到红包的个数递减输出;如果还有并列,则按个人编号递增输出。 刚开始没有仔细看题导致第一个测试点一直不能通过,最好理解的方法就是用结构体。AC代码 C语言#include <stdio.h>#include <stdlib.h>struct people{ int Ssno; //编号 int Sm...原创 2020-04-25 11:21:57 · 736 阅读 · 0 评论 -
(考前必看)L2-008 最长对称子串 (25分)
#include<stdio.h>#include<string.h>char str[1010];int main(){ int i,j,n,m,k,t,l; gets(str); l=strlen(str); for(i=l-1;i>=2;i--) { for(j=0;j+i<l;j++) ...原创 2020-04-25 09:39:41 · 476 阅读 · 0 评论 -
L2-006 树的遍历 (25分)
解析:通过递归的方法从树根向下依次构造一颗二叉树,然后通过层次遍历该树。所以根据中序和任意一个其他序列构造一颗二叉树的方法只需掌握一种,便可以推出另外一种的写法。AC代码:#include <stdio.h>#include <stdlib.h>typedef struct node{ int data; struct node *left; ...原创 2020-04-23 10:14:40 · 613 阅读 · 0 评论 -
L2-003 月饼 (25分)
/*本题需要注意的是,除了种类和最大需求量是整型数据,其他数据皆是小数,这意味着库存量也是小数而不是正整数,这个点是测试点2所要求的,如果不注意数据类型,很容易被卡住。*/#include <stdio.h>struct yuebin{ //注意必须全是double不然测试点2过不去 double AllPrice; double AllTo...原创 2020-04-22 10:39:53 · 383 阅读 · 0 评论 -
L1-059 敲笨钟 (20分) C语言
需要操作字符串的这类题一定不要操作字符串然后打印字符串,方法一定是不用修改字符串,直接打印部分字符串+遇到要修改的地方再加上题目要求的字符串打印#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ int n,i,j,flag = 0,k; scanf(...原创 2020-04-10 16:59:39 · 1146 阅读 · 0 评论 -
L1-054 福到了 (15分) C语言
#include <stdio.h>int main(){ char flag,ch; int i,n,j,count=0; scanf("%c%d",&flag,&n); getchar(); //接收缓冲区中的回车 char arr[n+1][n+1]; for(i=0;i<n;i++){ ...原创 2020-04-10 11:12:01 · 2737 阅读 · 0 评论 -
L1-039 古风排版 (20分)
#include <stdio.h>#include <string.h>int main(){ int n,i,j,k=0; scanf("%d",&n); char a[1001]; getchar(); gets(a); int t = strlen(a)/n; if(strlen(a)%n!=0...原创 2020-04-08 15:59:22 · 155 阅读 · 0 评论 -
L1-033 出生年 (15分) C语言
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int Jugement(int year,int num);int main(){ int year,num,count=0; scanf("%d %d",&yea...原创 2020-04-08 11:08:32 · 1425 阅读 · 1 评论 -
L1-025 正整数A+B (15分) C语言
认真读题:B中可能包含空格所以B不能用scanf来读取!!!#include <stdio.h>#include <stdlib.h>#include <string.h>int IsStanderd( char *A);int main(){ char A[20]; char B[20]; scanf("%s",A);...原创 2020-04-06 10:10:29 · 1226 阅读 · 1 评论 -
L1-023 输出GPLT (20分)
认真读题,调整顺序后输出#include <stdio.h>#include <string.h>int main(){ char a[10001]; gets(a); int i; int g=0,p=0,l=0,t=0; for(i=0;i<strlen(a);i++){ if(a[i]=='G'|...原创 2020-04-05 10:44:12 · 239 阅读 · 0 评论 -
L1-011 A-B (20分)
解决方案:先对B的所有字符进行标记,然后遍历A未标记过的直接输出#include <stdio.h>#include <stdlib.h>int main(){ char s1[10010]; char s2[10010]; gets(s1); gets(s2); int a[256]; memset(a,0,siz...原创 2020-04-04 10:23:29 · 562 阅读 · 1 评论 -
L1-058 6翻了 (15分)
思路:不要想着去操作字符串的删减,直接遍历字符串不是‘6’的字符直接打印,出现6再判断有几个6,在做相应打印操作。#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char str[1001]; gets(str); int i,count=...原创 2020-04-10 16:23:17 · 490 阅读 · 0 评论
分享