自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(33)
  • 收藏
  • 关注

转载 调用多线程的start方法时报错:start未定义 The method start() is undefined for the type SpeakElephant...

1.问题:调用多线程的start方法时报错:start未定义原因:主类的名字Thread和线程名Thread冲突,导致无法识别对多线程Thread方法的继承,故无法调用线程Thread的方法start()亦即public class Thread 的类名和后面public class SpeakCar extends Thread中的线程方法名Thread冲突;反思:下次给每个类...

2018-11-21 17:26:00 636

转载 Fibonacci 的Python实现

Fibonacci 的Python实现def fib(max): L = [1,1] i = 0 j = 0 if max == 0: return elif max == 1: return [1] elif max == 2: return L else: wh...

2018-11-15 13:17:00 457

转载 列表生成式的使用

输入:['Hello', 'World', 18, 'Apple', None]输出:['hello', 'world', 'apple']L = ['Hello', 'World', 18, 'Apple', None]print([w.lower() for w in L if isinstance(w, str)])# -- coding: utf-8 --L = ['...

2018-11-13 12:58:00 313

转载 请使用迭代查找一个list中最小和最大值,并返回一个tuple:# 测试 if findMinAndMax([]) != (None, None): print('测试失败!') elif f...

def findminmax(L): a = [] if L != a: min = L[0] max = L[0] for i in L: if min > i: min = i if max < i: ...

2018-11-12 22:22:00 335

转载 利用切片操作,实现一个trim()函数,去除字符串首尾的空格,注意不要调用str的strip()方法:# 测试: if trim('hello ') != 'hello': print('测...

def trim(s): k = 0 '''while循环判断输入字符串是否为空值''' while k < len(s): if s[k] == ' ': #如果是空字符则记录字符的个数 k = k + 1 #k自增来记录数值 else: #否则字符串中遇到非空格 ...

2018-11-09 12:07:00 222

转载 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He… 小组名和彗星名都以下列方式转换成一个数字:最终的数字就是名字中所有字母的积,其中AA是11,ZZ是2626。例如,USA...

完善后代码:#include <stdio.h>#include <stdlib.h>int main(){ int i, sum1, sum2; char str1[7], str2[7]; //数组开大一点,最多需要放六个字符外加一个字符串结束标志\0 sum1 = sum2 = 1; scanf("%s\n%s",...

2018-11-03 20:41:00 389

转载 P1055 ISBN号码 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括99位数字、11位识别码和33位分隔符,其规定格式如x-xxx-xxxxx-x,其中符号-就是分隔符(键盘上的...

#include <stdio.h>#include <stdlib.h>int main(){ int i, j, n, sum, id; int a[15]; char str[15]; scanf("%s", str); //输入ISBN号 j = 0; for(i=0; i<11; i++...

2018-11-02 21:48:00 2987

转载 P1567 统计天数 统计天数 题目描述 炎热的夏日,KC非常的不爽。他宁可忍受北极的寒冷,也不愿忍受厦门的夏天。最近,他开始研究天气的变化。他希望用研究的结果预测未来的天气。 经历千辛万苦,他收...

#include <stdio.h>#include <stdlib.h>int main(){ int i, N, n, m; int temp[10000000]; //数组要开足够大,不然(..>^^>..) scanf("%d", &N); for (i = 0; i < N; i++) ...

2018-10-30 22:17:00 2712

转载 P2141 珠心算测验 题目描述 珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术。珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得到普及。 某学校的珠心算老...

#include <stdio.h>#include <stdlib.h>int main(){ int i, j, k, n, b, m; int a[100]; scanf("%d", &n); //输入数据个数 for(i=0; i<n; i++) //循环输入正整数值 { ...

2018-10-28 21:15:00 2586

转载 P1428 小鱼比可爱 人比人,气死人;鱼比鱼,难死鱼。小鱼最近参加了一个“比可爱”比赛,比的是每只鱼的可爱程度。参赛的鱼被从左到右排成一排,头都朝向左边,然后每只鱼会得到一个整数数值,表示这只鱼的可...

#include <stdio.h>#include <stdlib.h>int main(){ int i, j, n; int a[100], b[100]; scanf("%d", &n); for(i=0; i<n; i++) //循环输入鱼的可爱数值 { scanf("%d"...

2018-10-28 20:00:00 1778

转载 P1427 小鱼的数字游戏 小鱼最近被要求参加一个数字游戏,要求它把看到的一串数字(长度不一定,以0结束,最多不超过100个,数字不超过2^32-1),记住了然后反着念出来(表示结束的数字0就不要念出...

#include <stdio.h>#include <stdlib.h>int main(){ int b, i, j; int a[101]; //定义数组 i = 0; b = 1; //用来辅助判断结束标志 while(b != 0) //判断是否为结束标志0 { scanf("...

2018-10-27 21:14:00 2908

转载 P1047 校门外的树 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是11米。我们可以把马路看成一个数轴,马路的一端在数轴00的位置,另一端在LL的位置;数轴上的每个整数点,即0,1...

#include<stdio.h> int main() { int L, M, i, j, n; int a[10001], b[10001]; scanf("%d %d",&L, &M); //输入L和M n = M*2; //循环输入b数组0~n的数据 for(i=0...

2018-10-27 19:17:00 8323

转载 P1046 陶陶摘苹果 陶陶家的院子里有一棵苹果树,每到秋天树上就会结出 1010 10个苹果。苹果成熟的时候,陶陶就会跑去摘苹果。陶陶有个 3030 30厘米高的板凳,当她不能直接用手摘到苹果的时候...

#include <stdio.h>#include <stdlib.h>int main(){ int appleh[10], benchh, taoh, bentaoh, i; benchh = 30; //板凳的高度 for (i=0; i<10; i++) //循环输入苹果的高度 { ...

2018-10-09 20:03:00 10397

转载 P1980 计数问题 试计算在区间 11 到 n n的所有整数中,数字 x(0 ≤ x ≤ 9)x(0≤x≤9)共出现了多少次?例如,在 11到 11 11中,即在 1,2,3,4,5,6,7,8,9...

#include <stdio.h>#include <stdlib.h>int main(){ int n, x, i, j, m, N, s[10], a, b, c, d, e, f, h; scanf("%d %d", &n, &x); m = 0; for (i=1; i<=n; i++) ...

2018-09-14 17:40:00 1230

转载 P1424 小鱼的航程(改进版) 有一只小鱼,它上午游泳150公里,下午游泳100公里,晚上和周末都休息(实行双休日),假设从周x(1<=x<=7)开始算起,请问这样过了n天以后,小鱼一共累计游泳了多...

#include <stdio.h>#include <stdlib.h>int main(){ long int n, i, week, distance; scanf("%ld %ld", &week, &n); distance = 0; for (i=0; i<n; i++) //n次循...

2018-09-13 17:52:00 4920

转载 P1423 小玉在游泳 小玉开心的在游泳,可是她很快难过的发现,自己的力气不够,游泳好累哦。已知小玉第一步能游2米,可是随着越来越累,力气越来越小,她接下来的每一步都只能游出上一步距离的98%。现在小...

#include <stdio.h>#include <stdlib.h>int main(){ int n; double first, needs, target, M; scanf("%lf", &target); first = 2.0; n = 1; needs = first; M...

2018-09-13 17:06:00 3253

转载 洛谷 P1035 级数求和 已知:S_n= 1+1/2+1/3+…+1/nS n ​ =1+1/2+1/3+…+1/n。显然对于任意一个整数KK,当nn足够大的时候,S_nS n ​ 大于KK...

#include <stdio.h>#include <stdlib.h>int main(){ int n, k; double s; scanf("%d", &k); s = 0.0; n = 1; while (1) //死循环 { s = s + 1.0/n...

2018-09-13 16:28:00 1724

转载 洛谷 P1008 三连击 将1,2, \cdots ,91,2,⋯,9共99个数分成33组,分别组成33个三位数,且使这33个三位数构成1:2:31:2:3的比例,试求出所有满足条件的33个三位数。 ...

#include <stdio.h>#include <stdlib.h>int main(){ int a[10], b[10], c[10], n1[999], n2[999], n3[999], s[10], i, j, k, f, t, r; //创建三个数组,用来存放1-9 t = 1; for (i=1; i<...

2018-09-11 15:43:00 743

转载 洛谷 P1085 不高兴的津津 输入格式: 输入包括77行数据,分别表示周一到周日的日程安排。每行包括两个小于1010的非负整数,用空格隔开,分别表示津津在学校上课的时间和妈妈安排她上课的时间。 输...

#include <stdio.h>#include <stdlib.h>int main(){ int s1[10], s2[10], c[10], d[10], a, i, j; i = 0; while (i < 7) //循环输入7组数据 { scanf("%d %d", &...

2018-09-09 16:04:00 650

转载 洛谷 P1909 买铅笔 输入格式: 第一行包含一个正整数nn,表示需要的铅笔数量。 接下来三行,每行用22个正整数描述一种包装的铅笔:其中第11个整数表示这种 包装内铅笔的数量,第22个整数表示这...

#include <stdio.h>#include <stdlib.h>int main(){ int s1[4], s2[4], c[4], a, number, box[4], i; scanf("%d", &number); //输入要购买的铅笔数 i = 0; while (i < 3) ...

2018-09-08 16:41:00 636

转载 洛谷P1089 津津的储蓄计划 输入格式: 1212行数据,每行包含一个小于350350的非负整数,分别表示11月到1212月津津的预算。 输出格式: 一个整数。如果储蓄计划实施过程中出现某个月钱不...

#include <stdio.h>#include <stdlib.h>#define M 300 //定义每月固定的零用钱int main(){ int i, a, d, c, saving = 0, balance = 0, N = 12, b[20]; i = 1; while( N-- ) //输入12个月的预...

2018-09-07 18:57:00 259

转载 pyinstaller打包exe执行文件错误 Unable to load the file system codec Can’t find module encodings...

![](https://images2018.cnblogs.com/blog/1354399/201807/1354399-20180718170602937-1632576285.png){"errorcode":-46628,"errormsg":"file not exist, retcode:-46628"}pyinstaller打包exe执行文件错误,python使用in...

2018-07-18 17:10:00 8731

转载 阶乘因式分解(一) 给定两个数m,n,其中m是一个素数。 将n(0<=n<=10000)的阶乘分解质因数,求其中有多少个m。 输入第一行是一个整数s(0<s<=100),表示测试数据的组数 ...

#include <stdio.h>int main() { int t,s,n,m; scanf("%d",&s); while(s--) { scanf("%d %d",&n,&m); t=0; for(;n>0;) { n=n/m; t+=n; } printf("%d\n",t); } }转载于:https:...

2018-05-21 10:45:00 187

转载 括号配对问题 描述 现在,有一行括号序列,请你检查这行括号是否配对。 输入第一行输入一个数N(0<N<=100),表示有N组测试数据。后面的N行输入多组输入数据,每组输入数据都是一个字符串S(S的长度...

#include <stdio.h>#include <string.h>int main() { char s1[20001],s[20001]; int N,a,i,j,len; scanf("%d",&N); while(N--) { j=0; s1[0]=0; scanf("%s",s); len=strlen(s); for(i=0;i...

2018-04-26 20:20:00 1769

转载 公约数和公倍数 描述 小明被一个问题给难住了,现在需要你帮帮忙。问题是:给出两个正整数,求出它们的最大公约数和最小公倍数。 输入第一行输入一个整数n(0<n<=10000),表示有n组测试数据; 随...

#include <stdio.h>int main() { int n,i,j,a,b,t,k; scanf("%d",&n); for(k=0;k<n;k++) { scanf("%d %d",&i,&j); a=i,b=j; if(b%a==0) printf("%d %d\n",a,i*j/a); else{ for(t=1;...

2018-04-19 21:19:00 695

转载 水仙花数 描述 请判断一个数是不是水仙花数。 其中水仙花数定义各个位数立方和等于它本身的三位数。 输入有多组测试数据,每组测试数据以包含一个整数n(100<=n<1000) 输入0表示程序输入结束。...

#include <stdio.h>int main() { int n,x,y,z; while(scanf("%d",&n)&&n!=0) { x=n/100; y=n%100/10; z=n%100%10; if(x*x*x+y*y*y+z*z*z==n) printf("Yes\n"); else printf("No\n"); }}...

2018-04-19 20:01:00 1553

转载 蛇形填数描述 在n*n方陈里填入1,2,...,n*n,要求填成蛇形。例如n=4时方陈为: 10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4 输入直接输入方陈的维数...

#include <stdio.h>int main() { int a[100][100]; int m,n,M,N,x,y,i,j,t=0; scanf("%d",&M); N=M;for(x=0,y=M-1;N>0;N=N-2,x++,y--) { for(m=x,n=y,i=0;i<N;i++,m++) { t++; a[m][n]=t; }...

2018-04-16 21:03:00 797

转载 设计一个从5个整数中取最小数和最大数的程序 输入输入只有一组测试数据,为五个不大于1万的正整数输出输出两个数,第一个为这五个数中的最小值,第二个为这五个数中的最大值,两个数字以空格格开。...

#include <stdio.h>int main() { int i,j,k,t; int c[10]; scanf("%d %d %d %d %d",&c[0],&c[1],&c[2],&c[3],&c[4]); for(i=0,k=1;i<4;i++,k++) { for(j=k;j<5;j++) { if(c...

2018-04-12 09:04:00 974

转载 Each test case is described by one line having the format "note tonality", where "note" is one of th...

#include <stdio.h>#include <string.h>int main() { int i=0; char s1[20],s2[20]; while(scanf("%s %s",s1,s2)!=EOF) { i++; if(strcmp(s1,"A#")==0) printf("Case %d: Bb %s\n",i,s2); els...

2018-04-10 17:03:00 147

转载 现在给出你一些数,要求你写出一个程序,输出这些整数相邻最近的素数,并输出其相距长度。如果左右有等距离长度素数,则输出左侧的值及相应距离。 如果输入的整数本身就是素数,则输出该素数本身,距离输出0...

#include <stdio.h>#include <math.h>int pro(int p);int main() { int a,n; scanf("%d",&n); while(n--) { scanf("%d",&a); pro(a); }}int pro(int p) { //求距离最近的素数及距离 int b,c,d,k,m,n,...

2018-04-03 19:19:00 757

转载 现在给你N个数(0<N<1000),现在要求你写出一个程序,找出这N个数中的所有素数,并求和。 第一行给出整数M(0<M<10)代表多少组测试数据 每组测试数据第一行给你N,代表该组测试数据的数量。...

#include <stdio.h>#include <math.h>int main() { int i,j,N,a=0,n,m,k; int s[1000]; scanf("%d",&N); while(N--) { scanf("%d",&n); for(j=0;j<n;j++) { scanf("%d",&s[j]); ...

2018-03-30 21:28:00 896

转载 无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递归地定义为 F(n)=1 ...........(n=1或n=2) F(n)=F(n-1)+F(n-2...

#include <stdio.h>int main() { int f[20],i,j,a,n; f[1]=1,f[2]=1; scanf("%d",&n); while(n--) { scanf("%d",&i); j=i-2,a=2; while(j--) { a++; f[a]=f[a-1]+f[a-2]; } printf(" %d...

2018-03-30 17:25:00 1244

转载 输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符。...

#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]) { int a,b,i,j=0,t; char c[20]; scanf("%d",&a); getchar(); for(i=0;i<a;i++) { scanf("%c%c%c",&c[j],&a...

2018-03-29 16:44:00 1212

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除