![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT基础编程习题集
许一城
一个学计算机的小学生。
展开
-
PAT基础编程习题集 4-7 统计某类完全平方数
#include <stdio.h>#include <math.h>int IsTheNumber ( const int N );int main(){ int n1, n2, i, cnt; scanf("%d %d", &n1, &n2); cnt = 0; for ( i=n1; i<=n2; i++ ) { if ( IsTheNumbe原创 2016-10-10 18:03:12 · 307 阅读 · 0 评论 -
PAT基础编程题目集 4-6 求单链表结点的阶乘和
4-6 求单链表结点的阶乘和原创 2016-10-10 17:41:06 · 259 阅读 · 0 评论 -
PAT基础编程题目集 4-8 简单阶乘计算
#include <stdio.h>int Factorial( const int N );int main(){ int N, NF; scanf("%d", &N); NF = Factorial(N); if (NF) printf("%d! = %d\n", N, NF); else printf("Invalid input\n"); re原创 2016-10-10 18:12:12 · 267 阅读 · 0 评论 -
PAT基础编程习题集 4-9 统计个位数字
#include <stdio.h>int Count_Digit ( const int N, const int D );int main(){ int N, D; scanf("%d %d", &N, &D); printf("%d\n", Count_Digit(N, D)); return 0;}int Count_Digit ( const int N原创 2016-10-10 18:23:15 · 417 阅读 · 0 评论 -
PAT基础编程题 4-10 阶乘计算升级版
#include <stdio.h>void Print_Factorial ( const int N );int main(){ int N; scanf("%d", &N); Print_Factorial(N); return 0;}void Print_Factorial ( const int N) { int fact[2568] = {0};原创 2016-10-12 19:05:46 · 336 阅读 · 0 评论 -
4-11 求自定类型元素序列的中位数
本题要求实现一个函数,求N个集合元素A[]的中位数,即序列中第⌊N/2+1⌋\lfloor N/2 +1\rfloor大的元素。其中集合元素的类型为自定义的ElementType。函数接口定义:ElementType Median( ElementType A[], int N );其中给定集合元素存放在数组A[]中,正整数N是数组元素个数。该函数须返回N个A[]元素的中位数,其值也原创 2017-01-16 11:40:32 · 395 阅读 · 0 评论 -
4-12 判断奇偶性
本题要求实现判断给定整数奇偶性的函数。函数接口定义:int even( int n );其中n是用户传入的整型参数。当n为偶数时,函数返回1;n为奇数时返回0。注意:0是偶数。裁判测试程序样例:#include int even( int n );int main(){ int n; scanf("%d", &n); if (eve原创 2017-01-16 11:50:04 · 309 阅读 · 0 评论 -
4-13 折半查找
给一个严格递增数列,函数int binSearch(SeqList T, KeyType k)用来二分地查找k在数列中的位置。函数接口定义:int binSearch(SeqList T, KeyType k)其中T是有序表,k是查找的值。裁判测试程序样例:#include using namespace std;#define MAXLEN 50typedef原创 2017-01-16 12:11:39 · 2716 阅读 · 0 评论 -
Python_15
1. __metaclass__=type#使用新类,否则super方法会出错class bird: def __init__(self): self.hungry=True def eat(self): if self.hungry: print 'Aaaah...' else: pri原创 2017-08-30 11:11:46 · 198 阅读 · 0 评论