- 博客(13)
- 收藏
- 关注
原创 编程题03 一元多项式的乘法与加法运算
#include<iostream>using namespace std;typedef int ElementType;typedef struct Node* ptrNode;typedef ptrNode LinkList;typedef ptrNode Position;struct Node { ElementType Coefficient; ElementType Exponent; Position Next;};LinkList CreatList(
2021-02-16 13:33:35 101
原创 编程题02 Maximum Subsequence Sum
#include<iostream>using namespace std;int main() { int a[100000], i, j, flag = 0, n; int ThisSum, MaxSum = -2147483648; int Maxi, Maxj; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] >= 0) flag = 1; } if (fl
2021-02-15 15:05:32 86
原创 函数题01 二分查找
#include<iostream>using namespace std;#define MAXSIZE 10#define NotFound 0typedef int ElementType;typedef int Position;typedef struct LNode* List;struct LNode { ElementType Data[MAXSIZE]; Position Last;};List ReadInput();Position Binary
2021-02-13 14:44:11 126
原创 函数题02 两个有序链表序列的合并
#include<iostream>using namespace std;typedef int ElementType;typedef struct Node* PtrToNode;typedef PtrToNode List;struct Node { ElementType Data; PtrToNode Next;};void Print(List L);List Read();List Merge(List L1, List L2);int main()
2021-02-13 14:18:48 127
原创 19打印杨辉三角
题目:打印出杨辉三角形public class MySolution{ public static void main(String args[]) { int [][]a=new int[10][10]; for(int i=0;i<10;i++) { a[i][i]=1; a[i][0]=1; } for(int i=2;i<10;i++) { for(int j=1;j<i;j++) { a[i][j]=a[i-1][j-1]+a[i-1
2021-02-04 14:18:24 52
原创 18冒泡排序
题目:对10个数进行排序import java.util.*;public class MySolution{ public static void main(String args[]) { Scanner s=new Scanner(System.in); int a[]=new int [10]; System.out.println("请输入10个整数:"); for(int i=0;i<10;i++) { a[i]=s.nextInt(); } for(
2021-02-04 11:23:20 113
原创 17字符串应用
题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。import java.util.*;public class MySolution{ public static void main(String args[]) { Scanner s=new Scanner(System.in); int a; do { System.out.print("请输入一个5位正整数:"); a=s.nextInt(); }while(a<1
2021-02-03 21:45:03 65
原创 16字符串
题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。import java.util.*;public class MySolution{ public static void main(String args[]) { Scanner s=new Scanner(System.in); System.out.print("input:"); long a=s.nextLong(); String ss=Long.toString(a); char[]
2021-02-03 21:38:08 90
原创 15递归法函数
题目:利用递归方法求输入数字的阶乘。import java.util.*;public class MySolution{ public static void main(String args[]) { Scanner s=new Scanner(System.in); System.out.print("input:"); int n=s.nextInt(); rec fr=new rec(); System.out.println(n+"!="+fr.rec(n)); }
2021-02-03 21:25:51 109
原创 14大数相加
题目:求1+2!+3!+…+20!的和public class MySolution{ public static void main(String args[]) { long sum=0; long fac=1; for(int i=1;i<=20;i++) { fac*=i; sum+=fac; } System.out.println(sum); }}
2021-02-03 21:16:54 63
原创 13字符数组的应用
题目:两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。public class MySolution{ static char[] m= {'a','b','c'}; static char[] n= {'x','y','z'}; public static void main(String args[]) { for(int i=0;i<m.lengt
2021-02-03 21:01:20 102
原创 12switch和函数的应用
题目:输入某年某月某日,判断这一天是这一年的第几天?import java.util.*;class input{ public int input() { int value=0; Scanner s=new Scanner(System.in); value=s.nextInt(); return value; }}public class MySolution{ public static void main(String args[]) { int year,m
2021-02-01 18:11:06 92
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人