diff --git a/.DS_Store b/.DS_Store index 60a1eda..64c46c9 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Data Structure/实验1-顺序表/A - 数据结构上机测试1:顺序表的应用.cp b/Data Structure/实验1-顺序表/A - 数据结构上机测试1:顺序表的应用.cp deleted file mode 100644 index 3b0c828..0000000 --- a/Data Structure/实验1-顺序表/A - 数据结构上机测试1:顺序表的应用.cp +++ /dev/null @@ -1,90 +0,0 @@ -/* - Description - 在长度为n(n<1000)的顺序表中可能存在着一些值相同的“多余”数据元素(类型为整型),编写一个程序将“多余”的数据元素从顺序表中删除,使该表由一个“非纯表”(值相同的元素在表中可能有多个)变成一个“纯表”(值相同的元素在表中只能有一个)。 - Input - 第一行输入表的长度n; - 第二行依次输入顺序表初始存放的n个元素值。 - Output - 第一行输出完成多余元素删除以后顺序表的元素个数; - 第二行依次输出完成删除后的顺序表元素。 - Sample - Input - 12 - 5 2 5 3 3 4 2 5 7 5 4 3 - Output - 5 - 5 2 3 4 7 - Hint - 用尽可能少的时间和辅助存储空间。 - */ -#include - -using namespace std; - -struct Node -{ - int data; - Node *Next; -}; - -int main() -{ - int n; - int count=0; - Node *head=new Node; - Node *p=head; - Node *res=new Node; - - p->Next=nullptr; - - cin>>n; - - for(int i=0;i>t->data; - t->Next=p->Next; - p->Next=t; - p=t; - } - Node *p3=res; - Node *p2=nullptr; - p=head->Next; - int flag=0; - while(p) - { - flag=0; - p2=res; - while(p2) - { - if(p2->data==p->data) - { - flag=1; - break; - } - p2=p2->Next; - } - - - if(flag==0) - { - Node *t=new Node; - t->data=p->data; - t->Next=p3->Next; - p3->Next=t; - p3=t; - count++; - } - p=p->Next; - } - - p=res->Next; - cout<data<<" "; - p=p->Next; - } - cout< -#include - -using namespace std; - -bool ar[5001][5001]; -int main() -{ - int m,n,u,v; - - while(scanf("%d %d",&n,&m)!=EOF)//!=EOF要快于~(按位取反) - { - memset(ar,0,sizeof (ar));//0要快于false - - while(m--) - { - scanf("%d %d",&u,&v); - ar[u][v]= 1; - } - - scanf("%d",&m); - - while(m--) - { - scanf("%d %d",&u,&v); - if(ar[u][v]==1) - printf("Yes\n"); - else - { - printf("No\n"); - } - } - } - - return 0; -} diff --git a/Data Structure/实验6-图/B - 图的基本存储的基本方式二.cp b/Data Structure/实验6-图/B - 图的基本存储的基本方式二.cp deleted file mode 100644 index bc46f86..0000000 --- a/Data Structure/实验6-图/B - 图的基本存储的基本方式二.cp +++ /dev/null @@ -1,68 +0,0 @@ -/* - Description - 请定一个无向图,顶点编号从0到n-1,用深度优先搜索(DFS),遍历并输出。遍历时,先遍历节点编号小的。 - - Input - 输入第一行为整数n(0 < n < 100),表示数据的组数。 对于每组数据,第一行是两个整数k,m(0 < k < 100,0 < m < k*k),表示有m条边,k个顶点。 下面的m行,每行是空格隔开的两个整数u,v,表示一条连接u,v顶点的无向边。 - - Output - 输出有n行,对应n组输出,每行为用空格隔开的k个整数,对应一组数据,表示DFS的遍历结果。 - - Sample - Input - 1 - 4 4 - 0 1 - 0 2 - 0 3 - 2 3 - Output - 0 1 2 3 - */ -#include -#include -#include - -using namespace std; - -vector a[500005]; - -int main() -{ - int n,m; - int u,v; - int q; - int len,flag; - while(scanf("%d %d",&n,&m)!=EOF) - { - memset(a,0,sizeof (a)); - while(m--) - { - scanf("%d %d",&u,&v); - a[u].push_back(v); - } - - scanf("%d",&q); - - while(q--) - { - flag=0; - - scanf("%d %d",&u,&v); - len=a[u].size(); - for(int i=0;i -int main() -{ - long long int i,n,m,j,x,t=0,y,max=0; - long long map[1000][1000],sum[8]={0}; - - scanf("%lld %lld",&n,&m); - - for(i=0;i=0;i--)//向上 - { - if (map[i][x]%2==0) - { - sum[1]+=map[i][x]; - map[i][x]=1; - } - } - - for(i=x;i>=0;i--)//向左 - { - if (map[y][i]%2==0) - { - sum[2]+=map[y][i]; - map[y][i]=1; - } - } - for(i=x;i=0&&j=0&&j>=0;i--,j--)//向左上 - { - if (map[i][j]%2==0) - { - sum[5]+=map[i][j]; - map[i][j]=1; - } - } - - for(i=y,j=x;i=0;i++,j--)//向左下 - { - if (map[i][j]%2==0) - { - sum[6]+=map[i][j]; - map[i][j]=1; - } - } - for(i=y,j=x;imax) - { - max=sum[i]; - } - } - - if (t!=0) - { - max=max+t; - } - - printf("%lld",max); - return 0; -} diff --git a/Test/2019ACM/.DS_Store b/Test/2019ACM/.DS_Store deleted file mode 100755 index fe388c4..0000000 Binary files a/Test/2019ACM/.DS_Store and /dev/null differ diff --git a/Test/2019ACM/守卫的DNA.c b/Test/2019ACM/守卫的DNA.c deleted file mode 100755 index 5e80589..0000000 --- a/Test/2019ACM/守卫的DNA.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - Description - 在Ljn计算出了湖深度后,船长Ljj为了奖励Ljn抓了稷下湖所有的鹅给Ljn吃,这个举动严重破坏了稷下湖的生态平衡,湖神为了惩罚他们,把他们关在自闭的荷花里,并由守卫看守。他们为了逃跑和守卫达进行了py交易,他们帮助守卫得出自己的DNA序列,然后守卫帮助他们从荷花中逃走。守卫有一个记录自己DNA序列的字符串,但因为污损其中的部分字符已经看不清以“?”代替,守卫的DNA由“A”“G”“C”“T”四种字符组成,且在字符串中这四个字符的数量都相等,现在你把“?”补充完整,得到守卫的DNA,守卫要求你构造出的字符串是所有情况中字典序最小的,如果存在这种字符串,请输出他,否则输出“impossible”(不包含引号)。 - - Input - 第一行包含一个整数n表示字符串的长度。(1≤n≤1000) - - 第二行输入一个长度为n的字符串。 - - Output - 如果能构造出来请输出构造出的字符串。 - - 否则否则输出“impossible”(不包含引号)。 - - Sample - Input - 8 - AG?C??CT - Output - AGACGTCT - */ -#include -#include -int main() -{ - char dna[1000],fl; - int a=0,c=0,g=0,t=0; - int len,i,max; - - scanf("%d",&len); - getchar(); - - if(len%4!=0) - { - printf("impossible\n"); - return 0; - } - - max=len/4; - gets(dna); - - for(i=0;imax||c>max||t>max||g>max) - { - printf("impossible\n"); - return 0; - } - - for(i=0;i -int main() -{ - long long int h,l; - double d; - - scanf("%lld %lld",&h,&l); - - d=(double)(l*l-h*h)/(2.0*h); - - printf("%.2lf\n",d); - - return 0; -} diff --git a/Test/2019ACM/机器数.c b/Test/2019ACM/机器数.c deleted file mode 100755 index 6941f71..0000000 --- a/Test/2019ACM/机器数.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - Description - - 计算机中的数据,其本质都是以二进制码存储。计算机系统的内存储器,是由许多称为字节的单元组成的,1个字节由8个二进制位构成,每位的取值为0或1。最右端的那1位称为“最低位”;最左端的那1位称为“最高位”。 - - 数字在计算机中的表示方法有原码、反码和补码。 - - 原码:最简单的机器数表示法。用最高位表示符号位,‘1’表示负号,‘0’表示正号。其其余位存放该数的绝对值的二进制。 - - 反码:正数的反码与原码相同,负数的反码符号位为1不变,其余各位按位取反(1变0、0变1) - - 补码:正数的补码与原码相同,负数的补码是在其反码的基础上+1。 - - 本题要求给定一个8位的原码,求出其补码。 - Input - - 第一行一个T(1= -int main() -{ - //此处不建议用int因为会有0开头的数,会导致结果少一位,本程序在第20行修补了这一错误 - //应用字符串型并且因为在ASCII码表中数字是顺序的所以可直接运算 - int i,num,t,T; - int n[8]; - - scanf("%d",&T); - - while(T--) - { - scanf("%d",&num); - t=num; - for(i=7;t>0;i--) - { - n[i]=t%10; - t=t/10; - } - if(i==0)//修补因为0开头的数字导致位数减少的问题 - { - n[0]=0; - } - if (n[0]==1) - { - for(i=1;i<8;i++) - { - n[i]=!n[i];//取反 - } - for(i=7;i>0;i--) - { - if(i==7) - { - n[i]=n[i]+1; - } - if (n[i]==2)//逢2进1 - { - n[i]=0; - n[i-1]=n[i-1]+1;//进位 - } - } - } - - for(i=0;i<8;i++) - { - printf("%d",n[i]); - } - printf("\n"); - } - return 0; -} -*/ -#include -int main() -{ - char a[8]; - int t,i; - scanf("%d",&t); - while (t--) - { - scanf("%s",a); - if (a[0] == '1') - { - for (i = 1; i < 8; i++) - { - if (a[i] == '1') - { - a[i] = '0'; - } - - else - { - a[i] = '1'; - } - } - } - - if (a[0] == '1') - - { - for (i = 7; i >= 0 ; i--) - { - if (i == 7) - { - a[i] = a[i] + 1; - } - if (a[i] == '2') - { - a[i] = '0'; - a[i - 1] = a[i - 1] + 1; - } - } - } - for (i = 0;i < 8;i++) - { - printf("%c",a[i]); - } - printf("\n"); - } - return 0; -} - diff --git a/Test/2019ACM/生化危机.c b/Test/2019ACM/生化危机.c deleted file mode 100755 index cbff290..0000000 --- a/Test/2019ACM/生化危机.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - Description - - 由于BHS公司制造了一种病毒,这种病毒可以将死去的人们,变成丧尸,这个公司通过贩卖这种病毒,来获取巨大的利益,而正义的ljj当然会阻止这种行为,在行动中由于失误,将这种病毒泄露了,从而感染了全球。将地球划分成一个由方格组成的地图,包含两个大写字母 W (代表未被感染的地区),B(代表感染的地区),为了让问题变得简单,一开始地球中所有地区都是未被感染的,病毒从一个中心往四周泄露,以正方形进行散,最终正方形边长是奇数,你能帮助 ljj 找到这个中心吗? - Input - - 输入一个整数N,代表地图一共有N行 (1<= N <=115) - - 然后输入N行字符串,每行保证长度一致为M(1 <= M <= 115) - - N行M列中包含两个字母(W,B)分别表示未感染的地区、感染的地区。 - Output - - 输出两个整数,x,y(1<=x<=N,1<=y<=M)代表病毒中心的位置。 - Sample - - Input - - 5 - - WWBBBW - - WWBBBW - - WWBBBW - - WWWWWW - - WWWWWW - Output - - 2 4 - */ -#include -#include -int main() -{ - int n,i,j,up=0,left=0,down=0,right=0; - char str[115][115]; - int x,y; - long int len; - scanf("%d",&n); - getchar();//吃回车 - - for(i=0;i -int main() -{ - int n, temp, i, temp2, c=0; - - scanf("%d", &n); - - i = 0; - while (n>=10) - { - temp=0; - - temp2=0; - - temp = n%10; - - temp2 = temp%2; - - if (temp2 == 0) - { - i = i+temp; - } - else - c = c+1; - - n = n/10; - - } - c = 0; - c = n%2; - if (c == 0) - { - i = i + n; - printf("%d\n",i); - } - else - printf("%d\n", i); - - return 0; -} diff --git a/Test/C/程序设计基础I/OJI 时间格式转换.c b/Test/C/程序设计基础I/OJI 时间格式转换.c deleted file mode 100755 index 19985e0..0000000 --- a/Test/C/程序设计基础I/OJI 时间格式转换.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - Description - - 24 小时制的时间格式为 "HH:mm",如 “05:20”,而 12 小时制的时间格式为 "h:mm AM/PM",如 "5:20 AM"。 - - 24 小时制到 12 小时制的对应关系如下: - - 0 时:12 时 (AM) - 1~11 时:1~11 时 (AM) - 12 时:12 时 (PM) - 13~23 时:1~11 时 (PM) - 例如:"00:00" 对应 "12:00 AM","01:20" 对应 "1:20 AM","12:35" 对应 "12:35 PM","13:17" 对应 "1:17 PM","23:59" 对应 "11:59 PM"。 - - - - 现在给你一个 24 小时制的时间,请你编写程序将其转换为 12 小时制的时间。 - Input - - 输入只有一行,包含一个 24 小时制的时间。 - Output - - 输出一行,表示转换为 12 小时制以后的时间。其中分钟部分若不足两位需要加 0 补足两位。 - Sample - - Input - - 00:05 - Output - - 12:05 AM - Hint - - 输入部分可以使用 scanf("%d:%d") 读入;输出的数字部分可以使用 printf("%d:%02d") 输出。 - */ -#include -int main () -{ - int h1, m1; - - int h2; - - scanf("%d:%02d", &h1, &m1); - - h2 = h1 - 12; - - if (h1 == 12) - printf("%d:%02d PM\n", h1, m1); - else if (h1 == 0) - printf("%d:%02d AM\n", -h2, m1); - else - { - if (h2 < 0) - printf("%2d:%02d AM\n", h1, m1); - - else - printf("%2d:%02d PM\n", h2, m1); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/字符串排序.c b/Test/C/程序设计基础I/字符串排序.c deleted file mode 100755 index 0ebf170..0000000 --- a/Test/C/程序设计基础I/字符串排序.c +++ /dev/null @@ -1,24 +0,0 @@ - -#include -#include -int main() -{ - int n,i,j; - char s[3][110],t[110]; - for(i=0;i<3;i++) - scanf("%s",s[i]); - for(i=0;i<2;i++) - for(j=i+1;j<3;j++) - if(strcmp(s[i],s[j])>0) - { - strcpy(t,s[i]); - strcpy(s[i],s[j]); - strcpy(s[j],t); - } - for(i=0;i<3;i++) - { - if(i==2) printf("%s\n",s[i]); - else printf("%s ",s[i]); - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-10转换字母(顺序结构).c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-10转换字母(顺序结构).c deleted file mode 100755 index adce585..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-10转换字母(顺序结构).c +++ /dev/null @@ -1,30 +0,0 @@ -/* - Description - - 从键盘上输入一个小写字母,然后将小写字母装换成大写字母输出! - Input - - 从键盘上输入一个小写字母。 - Output - - 小写字母装换成大写字母输出。 - - 解题思路: - 将一个小写字符转换成大写字符,只需要将这个字符ASCII减去32;将一个大写字符转换成小写字符,则给这个字符ASCII加上32 - A => a -32 - a => A +32 - */ -#include -int main() -{ - - char a; - - a = getchar(); - - a = a - 32; - - putchar(a); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-11实数的输出和占位.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-11实数的输出和占位.c deleted file mode 100755 index 41ddc14..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-11实数的输出和占位.c +++ /dev/null @@ -1,42 +0,0 @@ -/* -Description - -输入一个实数,请你按如下要求输出: - -第一行按双精度默认输出, - -第二行双精度数输出共占 10 位,其中 3 位小数,右对齐,左补空格并在两端添加星号包裹, - -第三行双精度数输出共占 10 位,其中 3 位小数,左对齐,右补空格并在两端添加星号包裹。 -Input - -一个double范围内的正实数 a 。 -Output - -共三行,按题目描述输出。 -Sample - -Input - -123.56789 -Output - -123.567890 -* 123.568* -*123.568 * - -*/ - -#include -int main() -{ - double a; - - scanf("%lf",&a); - - printf("%lf\n",a); - printf("*%10.3lf*\n",a); - printf("*%-10.3lf*\n",a); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-12大整数的输入输出.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-12大整数的输入输出.c deleted file mode 100755 index dcf1919..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-12大整数的输入输出.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - Description - - 输入两个 long long 范围内的整数,输出他们的和。 - Input - - 两个 long long 范围内的整数。 - Output - - 输出的两个大整数的和,保证结果在 long long 范围内。 - - */ -#include -int main() -{ - long long a,b,c; - - scanf("%lld %lld", &a, &b); - - c = a + b; - - printf("%lld",c); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-13带’ 和 ”字符的输出.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-13带’ 和 ”字符的输出.c deleted file mode 100755 index dc6cbe9..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-13带’ 和 ”字符的输出.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - Description - - 输入一个字符,输出两行。 - - 第一行将字符用 ' 包裹。 - - 第二行将字符用 " 包裹。 - Input - - 输入一个字符。 - Output - - 按题目描述输出。 - Sample - - Input - - A - Output - - 'A' - "A" - */ -#include -int main () -{ - char a; - - scanf("%c",&a); - - printf("\'%c\'\n",a); - printf("\"%c\"",a); - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-14'%'字符的输入输出.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-14'%'字符的输入输出.c deleted file mode 100755 index adb1559..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-14'%'字符的输入输出.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Description - - 输入三个用 `` \ `` 分割的正整数 a b c 代表日,月,年, - - 要求按照输入样式原样输出。 - Input - - 三个int范围内的正整数,中间用 `` \ `` 分割。 - Output - - 按题目描述原样输出。 - Sample - - Input - - 9\17\2018 - Output - - 9\17\2018 - -*/ -#include -int main() -{ - - int a, b, c; - char d, e; - - scanf("%d %c %d %c %d",&a, &d, &b, &e, &c); - - printf("%d%c%d%c%d", a, d, b, e, c); - - return 0; - -} diff --git "a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-15‘\\’字符的输入输出.c" "b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-15‘\\’字符的输入输出.c" deleted file mode 100755 index adb1559..0000000 --- "a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-15‘\\’字符的输入输出.c" +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Description - - 输入三个用 `` \ `` 分割的正整数 a b c 代表日,月,年, - - 要求按照输入样式原样输出。 - Input - - 三个int范围内的正整数,中间用 `` \ `` 分割。 - Output - - 按题目描述原样输出。 - Sample - - Input - - 9\17\2018 - Output - - 9\17\2018 - -*/ -#include -int main() -{ - - int a, b, c; - char d, e; - - scanf("%d %c %d %c %d",&a, &d, &b, &e, &c); - - printf("%d%c%d%c%d", a, d, b, e, c); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-16十六进制数输出和占位.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-16十六进制数输出和占位.c deleted file mode 100755 index 3ef06d3..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-16十六进制数输出和占位.c +++ /dev/null @@ -1,44 +0,0 @@ - /* - - Description - - 输入一个整数,请你按如下要求输出: - - 第一行按原样输出, - - 第二行以十六进制输出(字母小写), - - 第三行以十六进制输出(字母大写)。 - Input - - 一个int范围内的正整数 a 。 - Output - - 共三行,按题目描述输出。 - Sample - - Input - - 456 - Output - - 456 - 1c8 - 1C8 - - */ - #include - int main() - { - int a; - - scanf("%d",&a); - - printf("%d\n",a); - printf("%x\n",a); - printf("%X\n",a); - - return 0; - - } - diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-17八进制数输出和占位.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-17八进制数输出和占位.c deleted file mode 100755 index f34466f..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-17八进制数输出和占位.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - Description - - 输入一个整数,请你按如下要求输出: - - 第一行按原样输出, - - 第二行以八进制靠右输出,不足 8 位左补 0 并在两端添加星号包裹, - - 第三行以八进制靠左输出,不足 8 位右补空格并在两端添加星号包裹。 - Input - - 一个int范围内的正整数 a 。 - Output - - 共三行,按题目描述输出。 - Sample - - Input - - 123 - Output - - 123 - *00000173* - *173 * - - */ -#include -int main() -{ - int a; - - scanf("%d",&a); - - printf("%d\n",a); - printf("*%08o*\n",a); - printf("*%-8o*\n",a); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-18十进制输入输出和其它非空格占位.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-18十进制输入输出和其它非空格占位.c deleted file mode 100755 index c9f7b27..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-18十进制输入输出和其它非空格占位.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - Description - - 输入一个整数,请你按如下要求输出: - - 第一行按原样输出, - - 第二行整数靠右原样输出,不足 8 位左补 0 并在两端添加星号包裹, - - 第三行整数靠左原样输出,不足 8 位右补空格并在两端添加星号包裹。 - Input - - 一个int范围内的正整数 a 。 - Output - - 共三行,按题目描述输出。 - Sample - - Input - - 123456 - Output - - 123456 - *00123456* - *123456 * - - */ -#include -int main() -{ - int a; - - scanf("%d",&a); - - printf("%d\n",a); - printf("\*%08d\*\n",a); - printf("\*%-8d\*\n",a); - - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-19十进制输入输出和空格占位.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-19十进制输入输出和空格占位.c deleted file mode 100755 index 4bff1cc..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-19十进制输入输出和空格占位.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - Description - - 输入一个整数,请你按如下要求输出: - - 第一行按原样输出, - - 第二行按原样靠右输出,不足 8 位左补空格并在两端添加星号包裹, - - 第三行按原样靠左输出,不足 8 位右补空格并在两端添加星号包裹。 - Input - - 一个int范围内的正整数 a 。 - Output - - 共三行,按题目描述输出。 - Sample - - Input - - 123456 - Output - - 123456 - * 123456* - *123456 * - - */ -#include -int main() -{ - int a; - - scanf("%d", &a); - - printf("%d\n", a); - printf("*%8d*\n", a); - printf("*%-8d*\n", a); - - - return 0; -} - - diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-1Hello-World!(printf练习).c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-1Hello-World!(printf练习).c deleted file mode 100755 index ea6b46e..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-1Hello-World!(printf练习).c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int main() -{ - - printf("Hello World!"); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-20字符型数据输出和占位.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-20字符型数据输出和占位.c deleted file mode 100755 index a249c7c..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-20字符型数据输出和占位.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - Description - - 输入一个字符,请你按如下要求输出: - - 第一行字符数据默认输出, - - 第二行字符型数据输出共占 4 位,右对齐,左补 3 个空格并在两端添加星号包裹, - - 第三行字符型数据输出共占 4 位,左对齐,右补 3 个空格并在两端添加星号包裹。 - Input - - 输入一个字符 。 - Output - - 共三行,按题目描述输出。 - Sample - - Input - - c - Output - - c - * c* - *c * - - */ -#include -int main() -{ - char a; - - scanf("%c", &a); - - printf("%c\n", a); - printf("*%4c*\n", a); - printf("*%-4c*\n", a); - - return 0; - -} - diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-2计算A+B(顺序结构).c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-2计算A+B(顺序结构).c deleted file mode 100755 index 76c9c51..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-2计算A+B(顺序结构).c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -int main() -{ - int a; - int b; - int c; - - scanf("%d %d", &a, &b); - - c = a + b; - - printf("%d",c); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-3交换两个整数的值(顺序结构).c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-3交换两个整数的值(顺序结构).c deleted file mode 100755 index 22b8bff..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-3交换两个整数的值(顺序结构).c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -int main() -{ - int x,y, z; - - scanf("%d %d", &x, &y); - z = x; - x = y; - y = z; - - printf("%d %d",x,y); - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-4逆置正整数.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-4逆置正整数.c deleted file mode 100755 index 9c70298..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-4逆置正整数.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - Description - - 输入一个三位正整数,将它反向输出。 - Input - - 3位正整数。 - Output - - 逆置后的正整数。 - - */ -#include -int main() -{ - int a, b, c, d, e; - - scanf("%d", &a); - - b = a / 100; - c = (a / 10 - b * 10); - d = a - b * 100 - c * 10; - - e = (d * 100) + (c * 10) + b; - - printf("%d", e); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-5买糖果.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-5买糖果.c deleted file mode 100755 index 19bec7c..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-5买糖果.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - Description - - 小瑜是个爱吃糖果的馋鬼,天天嚷着要爸爸买糖果,可是爸爸很忙,哪有时间啊,于是就让小瑜自己去了,糖果3角钱一块,爸爸给小瑜n元钱,请你告诉小瑜最多能买几块糖,还剩几角钱? - Input - - 输入爸爸给小瑜的钱n元,n为整数。 - Output - - 小瑜最多能买回的糖块数以及剩下的钱(单位为:角),用空格分隔。 - */ -#include - -int main() -{ - int m,n,t,c; - - scanf("%d", &m); - - t = m*10; - - c = t % 3; - - n = t / 3; - - printf("%d %d", n, c); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-6三个整数的和、积与平均值.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-6三个整数的和、积与平均值.c deleted file mode 100755 index 0a886d8..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-6三个整数的和、积与平均值.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -int main() -{ - int a,b,c,d,e; - float f; - - scanf("%d %d %d", &a, &b, &c); - - d = a + b + c; - - e = a * b * c; - - f = (d + 0.00) / 3; - - printf("%d %d %.2f", d, e, f); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-7圆柱体计算.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-7圆柱体计算.c deleted file mode 100755 index 5f13a37..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-7圆柱体计算.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - int main () -{ - float pi = 3.1415926; - int r,h; - float L,S,SC,V; - - scanf("%d %d", &r, &h); - - L = pi * r * 2; - S = pi * r * r; - SC = L*h; - V = S * h; - - printf("%.2f %.2f %.2f %.2f", L, S, SC, V); - - return 0 ; -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-8温度转换.c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-8温度转换.c deleted file mode 100755 index cb4cc5e..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-8温度转换.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -int main() -{ - float C; - float F; - - scanf("%f",&F); - - C = 5*( F - 32 ) / 9; - - printf("%.2f",C); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-9单个字符输入和输出(顺序结构).c b/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-9单个字符输入和输出(顺序结构).c deleted file mode 100755 index fa81997..0000000 --- a/Test/C/程序设计基础I/实验1--顺序结构程序设计/OJ1-9单个字符输入和输出(顺序结构).c +++ /dev/null @@ -1,25 +0,0 @@ -/* - Description - - 用getchar()从键盘上输入一个字符,用putchar()打印出来! - Input - - 从键盘上输入一个字符! - Output - - 把刚刚输入的字符打印出来! - - */ - -#include - int main () -{ - int a; - - a = getchar(); - - putchar(a); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-10找中间数.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-10找中间数.c deleted file mode 100755 index e4a49dd..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-10找中间数.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - Description - 输入三个整数,找出其中的中间数。(这里的中间数指的是大小,不是位置。) - - Input - 输入3个整数。 - - Output - 输出中间数。 - - Sample - Input - 1 2 3 - Output - 2 - */ -#include -int main () -{ - int a, b, c, t; - - scanf("%d %d %d", &a, &b, &c); - - if ( a < b ) - { - //交换ab的数值 - t = a; - a = b; - b = t; - } - if ( b < c ) - { - //交换bc的数值 - t = b; - b = c; - c = t; - } - if (b > a) - { - //交换ac的数值 - t = b; - b = a; - a = t; - } - - printf ("%d\n", b); - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-11整除.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-11整除.c deleted file mode 100755 index 4663f6b..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-11整除.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - Description - 判断一个数n能否同时被3和5整除。 - - Input - 输入一个正整数n。 - - Output - 如果能够同时被3和5整除,输出Yes,否则输出No。 - - Sample - Input - 15 - Output - Yes - */ -#include -int main () -{ - int a; - - scanf("%d", &a); - - if (( a % 3 == 0) && (a % 5 == 0) ) - printf("Yes"); - else - printf("No"); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-12闰年.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-12闰年.c deleted file mode 100755 index 704e75d..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-12闰年.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - Description - 时间过得真快啊,又要过年了,同时,我们的人生也增长了一年的阅历,又成熟了一些。可是,你注意过今年是不是闰年呢,明年呢? - Input - 只有一个整数year,代表年份。 - - Output - 如果是闰年输出Yes,否则输出No。 - - Sample - Input - 2000 - Output - Yes - */ -#include -int main () -{ - int year; - - scanf("%d", &year); - - if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) - printf("Yes\n"); - else - printf("No\n"); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-13C:C++经典程序训练3---模拟计算器.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-13C:C++经典程序训练3---模拟计算器.c deleted file mode 100755 index a7cc79f..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-13C:C++经典程序训练3---模拟计算器.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - Description - 简单计算器模拟:输入两个整数和一个运算符,输出运算结果。 - - Input - 第一行输入两个整数,用空格分开; - 第二行输入一个运算符(+、-、*、/)。 - 所有运算均为整数运算,保证除数不包含0。 - - Output - 输出对两个数运算后的结果。 - - Sample - Input - 30 50 - * - Output - 1500 - */ -#include -int main () -{ - int a, b, sum; - char c; - - scanf("%d %d", &a, &b); - scanf(" %c", &c); - - if (a != 0 && b != 0) - { - - if ('+' == c) - { - sum = a + b; - printf("%d", sum); - } - - else if ('-' == c) - { - sum = a - b; - printf("%d", sum); - } - - else if ('*' == c) - { - sum = a * b; - printf("%d", sum); - } - - else if ('/' == c) - { - sum = a / b; - printf("%d", sum); - } - } - else return 0; - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-14某年某月的天数.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-14某年某月的天数.c deleted file mode 100755 index 362e869..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-14某年某月的天数.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - Description - 输入三个整数a,b,c。并进行两两相加,最后比较相加和的最大值。 - Input - 输入数据包含三个整数,用空格分开。 - Output - 输出两两相加后的最大值。 - Sample - Input - 1 2 3 - Output - 5 - */ -#include -#include - -int main() -{ -int y,m,d; -scanf("%d\\%d",&y,&m);//输入\时用\\转义 -switch(m) -{ -case 1: -case 3: -case 5: -case 7: -case 8: -case 10: -case 12:d=31;break; -case 4: -case 6: -case 9: -case 11:d=30;break; -case 2: -if((y%4==0&&y%100!=0)||(y%400==0)) -d=29; -else -d=28; -} -printf("%d\n",d); -return 0; -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-15C语言实验——输入数字星期,输出英文(switch语句).c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-15C语言实验——输入数字星期,输出英文(switch语句).c deleted file mode 100755 index 0b91619..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-15C语言实验——输入数字星期,输出英文(switch语句).c +++ /dev/null @@ -1,71 +0,0 @@ -/* - Description - - 从键盘上输入数字星期,然后输出它的英文。 - 其对应关系是: - 1 Monday - 2 Tuesday - 3 Wednesday - 4 Thursday - 5 Friday - 6 Saturday - 7 Sunday - Input - - 从键盘输入数字星期,输入数字在1-7之间。 - Output - - 输出该数字对应的英文星期表示。 - Sample - - Input - - 2 - Output - - Tuesday - */ -#include -int main () -{ - int nu; - - scanf("%d", &nu); - - switch (nu) - { - case 1: - printf("Monday"); - break; - - case 2: - printf("Tuesday"); - break; - - case 3: - printf("Wednesday"); - break; - - case 4: - printf("Thursday"); - break; - - case 5: - printf("Friday"); - break; - - case 6: - printf("Saturday"); - break; - - case 7: - printf("Sunday"); - break; - - default: - break; - } - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-1C语言实验——求绝对值(选择结构).c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-1C语言实验——求绝对值(选择结构).c deleted file mode 100755 index 87b3e9b..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-1C语言实验——求绝对值(选择结构).c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Description - - 从键盘输入两个时间点(24小时制),输出两个时间点之间的时间间隔,时间间隔用“小时:分钟:秒”表示。 - 如:3点5分25秒应表示为--03:05:25.假设两个时间在同一天内,时间先后顺序与输入无关。 - Input - - 输入包括两行。 - 第一行为时间点1。 - 第二行为时间点2。 - Output - - 以“小时:分钟:秒”的格式输出时间间隔。 - 格式参看输入输出。 - Sample - - Input - - 12:01:12 - 13:09:43 - Output - - 01:08:31 - */ -#include - -int main() -{ - int a; - - scanf("%d", &a); - - if (a<0) - printf("%d", -a); - else - printf("%d", a); - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-2C语言实验——时间间隔.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-2C语言实验——时间间隔.c deleted file mode 100755 index 9f15b83..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-2C语言实验——时间间隔.c +++ /dev/null @@ -1,99 +0,0 @@ - -/* - Description - - 从键盘输入两个时间点(24小时制),输出两个时间点之间的时间间隔,时间间隔用“小时:分钟:秒”表示。 - 如:3点5分25秒应表示为--03:05:25.假设两个时间在同一天内,时间先后顺序与输入无关。 - Input - - 输入包括两行。 - 第一行为时间点1。 - 第二行为时间点2。 - Output - - 以“小时:分钟:秒”的格式输出时间间隔。 - 格式参看输入输出。 - Sample - - Input - - 12:01:12 - 13:09:43 - Output - - 01:08:31 - */ - -#include -int main() -{ - int a,b,d,e,f,g,i, j, k, s2, m2, h2; - char c; - - scanf("%d %c %d %c %d", &a, &c, &b, &c, &d); - scanf("%d %c %d %c %d", &e, &c, &f, &c, &g); - - //大小置换 - if (a < e) - { - h2 = a; - a = e; - e = h2; - - m2 = b; - b = f; - f = m2; - - s2 = d; - d = g; - g = s2; - } - else - { - a = a; - b = b; - d = d; - e = e; - f = f; - g = g; - } - - i = a - e; - j = b - f; - k = d - g; - - // 秒 - if (k < 0) - { - k = 60 + k; - j = j - 1; - } - - else - k = k; - // 分 - if (j < 0) - { - j = 60 + j; - i = i - 1; - } - - else if (j >= 60) - { - j = j - 60; - i = i + 1; - } - else if (j >=0 && j <= 60) - j = j; - // 时 - if (i < 0) - i = - i; - else - i = i; - - printf("%02d%c%02d%c%02d", i, c, j, c, k); - - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-3C语言实验——求两个整数之中较大者.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-3C语言实验——求两个整数之中较大者.c deleted file mode 100755 index 3bfc421..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-3C语言实验——求两个整数之中较大者.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - Description - - 输入两个整数,请编程求其中的较大者。 - Input - - 在一行中输入用空格隔开的两个整数,例如5 9。 - Output - - 输出两个整数之中较大者,输出形式举例:max=9。 - Sample - - Input - - 5 9 - Output - - max=9 - */ -#include -int main () -{ - int a, b; - - scanf("%d %d", &a, &b); - - if (a>b) - printf("max=%d", a); - else - printf("max=%d", b); - - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-4小鑫吃苹果.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-4小鑫吃苹果.c deleted file mode 100755 index 1057e97..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-4小鑫吃苹果.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - Description - 每年平安夜的时候妈妈都会给小鑫邮寄两个大苹果,两个苹果的重量分别为x,y。以前小鑫都是自己默默的吃掉两个大苹果,但是这次小鑫决定要把最重的苹果送给他的女神。可惜他比较笨分不出哪个苹果重哪个苹果轻,所以请你帮他找到最重的苹果,输出最重的重量。 - - Input - 单组输入。 - 两个正整数表示苹果的重量x,y(1 <= (x, y) <= 1000) - Output - 输出两个苹果中最重的重量。 - Sample - Input - 100 200 - Output - 200 - */ -#include -int main () -{ - int x, y; - - scanf("%d %d", &x, &y); - - if (x>y) - printf("%d", x); - else - printf("%d", y); - - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-5小鑫の日常系列故事(一)——判断对错.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-5小鑫の日常系列故事(一)——判断对错.c deleted file mode 100755 index 62b16b7..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-5小鑫の日常系列故事(一)——判断对错.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - Description - - 话说小鑫可是一个奇人,在他刚出生的时候,就能口算出1000000以内的加法。因为他有这样一项能力,他的父母专门雇佣了一位可爱的保姆姐姐(内部消息不超过二十岁哦)来训练他。可是这位保姆姐姐有时候脑袋会秀逗一下,如果被小鑫的父母发现了可是要丢掉工作的。于是她找到了身为程序员的你,你能用你的双手来帮助他解决问题么? - Input - - 输入有两行,第一行为两个整数a,b(a,b>0)。第二行为一个数,为小鑫对于a+b口算出的答案。 - Output - - 输出为一行。判断小鑫给出的答案是否正确,如果是输出“YES”,否则输出“NO”。(输出不包括引号) - Sample - - Input - - 1 2 - 3 - Output - - YES - */ -#include -int main () -{ - int a, b, c; - - scanf("%d %d %d", &a, &b, &c); - - - if (c == a + b) - printf("YES\n"); - else - printf("NO\n"); - - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-6小鑫追女神.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-6小鑫追女神.c deleted file mode 100755 index 9103e58..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-6小鑫追女神.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - Description - 小鑫长得比较丑,但还是对女神垂涎不止,小鑫向女神表白了。女神毕竟是女神,女神的世界里,只有0和1。0代表女神拒绝了他,1代表女神接受了他。现在你需要判断女神到底是接受了他还是拒绝了他。若接受,输出“I like you”(不包括引号),若拒绝,输出“He he”(不包括引号)。 - - Input - 单组输入。 - 输入只有一个数,保证只有0或1。 - Output - 输出女神对小鑫的态度,“I like you”(不包括引号)或“He he”(不包括引号) - Sample - Input - 0 - Output - He he - Hint - - */ -#include -int main() -{ - int a; - - scanf("%d", &a); - - if (a == 1) - printf("I like you\n"); - else if (a == 0) - printf("He he\n"); - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-7求三个整数的最大值.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-7求三个整数的最大值.c deleted file mode 100755 index a6fa5f4..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-7求三个整数的最大值.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - Description - 请编写程序,输入三个整数,求出其中的最大值输出。 - - Input - 在一行上输入三个整数,整数间用逗号分隔。 - - Output - 输出三个数中的最大值。 - - Sample - Input - 5,7,9 - Output - max=9 - */ -#include -int main () -{ - int a,b,c,t,max; - scanf("%d,%d,%d",&a,&b,&c); - if(a>b) - { - t=a; - a=b; - b=t; - - } - if(a>c) - { - t=a; - a=c; - c=t; - - } - if(b>c) - { - t=b; - b=c; - c=t; - - } - max=c; - - printf("max=%d\n",max); - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-8相加和最大值.c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-8相加和最大值.c deleted file mode 100755 index 205e07c..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-8相加和最大值.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - Description - 输入三个整数a,b,c。并进行两两相加,最后比较相加和的最大值。 - Input - 输入数据包含三个整数,用空格分开。 - Output - 输出两两相加后的最大值。 - Sample - Input - 1 2 3 - Output - 5 - */ -#include -int main() -{ - - int a, b, c, d, e, f, t, max; - - scanf("%d %d %d",&d,&e,&f); - - a = d + e; - b = d + f; - c = e + f; - - - - if(a>b) - { - t=a; - a=b; - b=t; - - } - if(a>c) - { - t=a; - a=c; - c=t; - - } - if(b>c) - { - t=b; - b=c; - c=t; - - } - max=c; - - printf("%d\n",max); - return 0; - - - return 0; - -} diff --git a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-9从大到小输出a、b、c(选择结构).c b/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-9从大到小输出a、b、c(选择结构).c deleted file mode 100755 index 7fb1b4f..0000000 --- a/Test/C/程序设计基础I/实验2--选择结构程序设计/OJ2-9从大到小输出a、b、c(选择结构).c +++ /dev/null @@ -1,50 +0,0 @@ -/* - Description - 从键盘输入三个整数a、b、c,要求将输出的数据按从大到小排序后输出。 - - Input - 从键盘上输入三个整数a、b、c,每个整数之间用空格分开。 - - Output - 从大到小顺序输出a、b、c的值。 - - Sample - Input - 4 3 5 - Output - 5 4 3 - */ -#include -int main () -{ - int a, b, c, t; - - scanf("%d %d %d", &a, &b, &c); - - if ( a < b ) - { - //交换ab的数值 - t = a; - a = b; - b = t; - } - if ( b < c ) - { - //交换bc的数值 - t = b; - b = c; - c = t; - } - if (b > a) - { - //交换ac的数值 - t = b; - b = a; - a = t; - } - - printf ("%d %d %d\n", a, b, c); - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (I).c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (I).c deleted file mode 100755 index a1e7e23..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (I).c +++ /dev/null @@ -1,38 +0,0 @@ -/* - Description - - Your task is to Calculate a + b. - - Too easy?! Of course! I specially designed the problem for acm beginners. - - You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim - Input - - The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line. - Output - - For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. - Sample - - Input - - 1 5 - 10 20 - Output - - 6 - 30 - */ -#include -int main() -{ - int a,b; - - while(scanf("%d %d", &a,&b) != EOF) - { - printf("%d\n",a+b); - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (III).c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (III).c deleted file mode 100755 index aaaea7c..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (III).c +++ /dev/null @@ -1,37 +0,0 @@ -/* - Description - - Your task is to Calculate a + b. - Input - - Inputcontains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed. - Output - - For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. - Sample - - Input - - 1 5 - 10 20 - 0 0 - Output - - 6 - 30 - */ -#include -int main() -{ - int a,b; - - while(scanf("%d %d", &a,&b) !=EOF) - { - if (a!=0||b!=0) - printf("%d\n",a+b); - else - break; - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (VII).c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (VII).c deleted file mode 100755 index c8bf076..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/A+B for Input-Output Practice (VII).c +++ /dev/null @@ -1,36 +0,0 @@ -/* - Description - - Your task is to Calculate a + b. - Input - - The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line. - Output - - For each pair of input integers a and b you should output the sum of a and b, and followed by a blank line. - Sample - - Input - - 1 5 - 10 20 - Output - - 6 - - 30 - */ -#include -int main() -{ - int a,b; - - while(scanf("%d %d", &a,&b) !=EOF) - { - printf("%d",a+b); - printf("\n"); - printf("\n"); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/N 计算球体积.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/N 计算球体积.c deleted file mode 100755 index fff4d92..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/N 计算球体积.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - Description - - 根据输入的半径值,计算球的体积。 - Input - - 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。 - Output - - 输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。 - Sample - - Input - - 1 - 1.5 - Output - - 4.189 - 14.137 - Hint - - 已知 PI = 3.1415927 - - #define PI 3.1415927 - */ -#include -#define PI 3.1415927 - -int main() -{ - double r; - double v=0; - - while (scanf("%lf", &r)!=EOF) - { - v = (4.0*PI*r*r*r)/3.0; - printf("%.3lf\n", v); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-10计算球体积.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-10计算球体积.c deleted file mode 100755 index f459d3f..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-10计算球体积.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Description - - 根据输入的半径值,计算球的体积。 - Input - - 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径。 - Output - - 输出对应的球的体积,对于每组输入数据,输出一行,计算结果保留三位小数。 - Sample - - Input - - 1 - 1.5 - Output - - 4.189 - 14.137 - Hint - - #define PI 3.1415927 - - */ -#include -#define pi 3.1415927 -int main () -{ - double r1, v1; - - while (scanf("%lf", &r1) != EOF) - { - v1 = (pi * r1 * r1 * r1) * (double)4/3; - - printf("%.3lf\n", v1); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-11洗衣服.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-11洗衣服.c deleted file mode 100755 index 18bb8b7..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-11洗衣服.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - Description - - X是一个勤劳的小孩,总是会帮助大人做家务。现在他想知道对于一根长为L的绳子能晾开多少件宽为W的衣服,显然这些衣服不能相互叠压。 - Input - - 多组输入。 - 每组输入两个整数L,W。 - Output - - 输出答案。 - Sample - - Input - - 10 5 - 10 4 - Output - - 2 - 2 - */ -#include -int main () -{ - - int l, w, n; - - while (scanf("%d%d", &l, &w) != EOF) - { - n = l/w; - printf("%d\n", n); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-12压岁钱-整数判断(存疑).c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-12压岁钱-整数判断(存疑).c deleted file mode 100755 index a424b31..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-12压岁钱-整数判断(存疑).c +++ /dev/null @@ -1,106 +0,0 @@ -/* - - Description - - SuShan过年要给孩子们发压岁钱喽,由于家里孩子很多,这可急坏了SuShan。你肯定以为她在担心钱不够,那你错了,她可是个有钱人儿,不差钱儿。她担心的是每个人分多少从而保证公平。 - SuShan从瑞士银行提出1000000来给孩子们分,由于来的孩子的数目不确定,所以SuShan希望你能帮他计算一下每个孩子给多少钱,从而保证每个孩子得到的都是整数。 - Input - - 输入有多组数据,第一行 T 代表数据的组数。 - 接下来有 T 行,每行一个整数 N,代表孩子的数目,1<= N <= 10000000。 - - - Output - - 只有一行。如果能够分给每个孩子相同数目的压岁钱,且都是整数,则输出每个孩子得到的钱数。否则输出No。 - - Sample - - Input - - 3 - 1 - 2 - 3 - Output - - 1000000 - 500000 - No - - - */ -#include -int main() -{ - int n, x; - double a; - int money = 10000000; - - scanf("%d", &x); - - while (x--) - { - scanf("%d", &n); - - if (1 <= n && money >=n) - { - a = (double)money / n; - if (a != (int)a) - { - printf("No\n"); - } - else - printf("%.0lf\n", a); - } - else - { - return 0; - } - - } - return 0; -} - -#include -int main() -{ - int T, N,c,a; - T= 0; - scanf("%d",&T); - - while (T>0) - { - scanf("%d",&N); - a = 1000000%N; - c = 1000000/N; - if (a==0) - printf("%d\n",c); - else - printf("NO\n"); - T=T-1; - - } - - return 0; -} - - - -#include -int main() -{ - int money=1000000; - int i; - int n; - scanf("%d",&i); - while(i--) - { - scanf("%d",&n); - if (money % n == 0) - printf("%d\n",money/n); - else - printf("No\n"); - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-1数列求和3.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-1数列求和3.c deleted file mode 100755 index adeaa7d..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-1数列求和3.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - - Description - - 正整数序列是指从1开始的序列,例如{1,2,3,4,......} - - 给定一个整数 n,现在请你求出正整数序列 1 - n 的和。 - Input - - 输入一个整数 n 。(1 <= n <= 1000) - Output - - 输出一个整数,即为正确答案。 - Sample - - Input - - 2 - Output - - 3 - - */ - -#include -int main () -{ - int n, i; - int sum = 0; - - scanf("%d", &n); - i = 1; - while (i<=n) - { - sum = sum + i; - - ++i; - } - printf("%d\n",sum); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-2数位数.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-2数位数.c deleted file mode 100755 index 945995f..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-2数位数.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - - Description - - 输入一个正整数N,求出N^3的各位数字的立方和。 - Input - - 输入N的值。N<=1024 - Output - - 问题描述中所要求的数值。 - Sample - - Input - - 3 - Output - - 351 - - */ -#include -int main() -{ - int n, s; - - scanf("%d", &n); - - s = n * n * n; - - printf("%d", s); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-3N^3问题.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-3N^3问题.c deleted file mode 100755 index c79f59d..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-3N^3问题.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - - Description - - 输入一个正整数N,求出N^3的各位数字的立方和。 - Input - - 输入N的值。N<=1024 - Output - - 问题描述中所要求的数值。 - Sample - - Input - - 3 - Output - - 351 - - */ -#include -int main() -{ - int n, c, a, sum=0; - - scanf("%d", &n); - - n = n * n * n; - - while(n>0) - { - a = n % 10; - n = n / 10; - c = a * a * a; - sum = sum + c; - } - printf("%d\n",sum); -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-4小树快长高.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-4小树快长高.c deleted file mode 100755 index 15efd91..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-4小树快长高.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - - Description - - 小明在植树节种了一棵小树,小明非常关心小树,每天都给小树浇水,盼望着小树快快长高。他知道小树现在有 n cm,每天长高k cm,他想知道多少天小树可以长到m cm。 - Input - - 输入三个整数 n, m, k。 ( 0 <= n<= 10000, 0 <= m <= 10000,0 <= k <= 10000) - Output - - 输出一个整数,即需要的天数。 - Sample - - Input - - 100 200 5 - Output - - 20 - - */ - -#include -int main() -{ - int n,m,k,t=0; - scanf("%d %d %d",&n,&m,&k); - while(m>n) - { - m = m - k; - t++; - } - printf("%d\n",t); - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-5偶数数位求和.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-5偶数数位求和.c deleted file mode 100755 index fefe49d..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-5偶数数位求和.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Description - - 给定一个整数,请求出这个整数所有数位中是偶数的数位的和。例如,对于12436546,那么答案就是 2 + 4 + 6 + 4 + 6 。 - Input - - 输入一个数 n 。 (0 <= n <= 2147483647) - Output - - 输出 n 的所有偶数数位的和。 - Sample - - Input - - 6768 - Output - - 20 - - */ -#include -int main () -{ - int n, i, a, j; - - scanf("%d", &n); - - i = 0; - while (n > 0) - { - a = n %10; - n = n / 10; - j = a %2; - - if (j == 0) - i = i + a; - - else - n = n; - - } - printf("%d\n", i); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-6小粉的难题.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-6小粉的难题.c deleted file mode 100755 index 0721427..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-6小粉的难题.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - - Description - - 小粉和哈士奇是好朋友,一天,哈士奇去找小粉玩,但小粉还没做完功课。粉妈妈说只有做完功课才能出门,这可急坏了小粉,于是小粉让哈士奇和他一块做功课。其中有一道题是这样的: - - 给出一个正整数 n 和数字 m ( m 取值范围[0,9]中的一个数字),求 m 在 n 中出现的次数。 - - 比如 n = 2122345 , m = 2,答案就是 3 ,因为 2 在 2122345 中出现了三次。 - - 哈士奇的数学不好,为了尽快做完功课,他找到了会编程的你,请你编写程序解决这个问题。 - Input - - 输入只有一行,包含两个空格分开的整数 n 和 m 。(0 <= m <= 9,1 <= n <= 2147483647) - Output - - 输出一个数字,表示 m 在 n 中 出现的次数。 - Sample - - Input - - 2122345 2 - Output - - 3 - - */ -#include -int main() -{ - int n, m, a, i; - - scanf("%d %d", &n, &m); - - if ((0 <= m && m <= 9)&&(1 <= n && n <= 214748364)) - { - i = 0; - while (n > 0) - { - a = n%10; - n = n/10; - - if (a == m) - { - ++i; - } - else - n = n; - } - } - else - return 0; - - printf("%d\n", i); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-7小金问呀问不会问题.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-7小金问呀问不会问题.c deleted file mode 100755 index 37f900d..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-7小金问呀问不会问题.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - - Description - - 众所周知,C语言的学习是我们程序设计基础的重点和主要内容。 - 小金在班里是一个爱学习的好孩子,但是他的编程能力却有点差,不过他坚信自己一定可以进步并追上其他同学。 - - Input - - 多组输入。 - 从键盘读入一个整数n,如果n >= 0代表小金考试进步了,如果n < 0代表小金退步了。 - Output - - 如果小明进步了输出”Yes”,反之输出”No”。输出不包括引号,输入输出各占一行,保证数据合法。 - Sample - - Input - - 100 - -100 - Output - - Yes - No - - */ -#include -int main() -{ - int n; - - while(scanf("%d", &n) != EOF) - { - if (n >= 0) - printf("Yes\n"); - else - printf("No\n"); - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-8优越数.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-8优越数.c deleted file mode 100755 index a4b020c..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-8优越数.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - - Description - - - 给定3个数,如果有两个数大于他们的平均数则称这组数为优越数。(定义纯属虚构) - Input - - - 输入第一行是一个整数: 表示测试数据的组数。 - 对于每组测试数据,仅一行3个整数。 - Output - - - 对于每组输入数据输出一行,判断它是否为一组优越数,如果是输出“Yes”(输出不包括引号),否则输出“No”。 - Sample - - Input - - 2 - 1 2 3 - 1 4 4 - Output - - No - Yes - - */ -#include -int main () -{ - int a, n1, n2, n3; - int e, s; - - scanf("%d", &a); - - while (scanf("%d %d %d", &n1, &n2, &n3)!= EOF) - { - s = n1 + n2 + n3; - e = (float)s / 3; - if ((n1 > e && n2 > e) || (n1 > e && n3 >e)||(n2 > e && n3 >e)) - printf("Yes\n"); - else - printf("No\n"); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-9分段函数求值.c b/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-9分段函数求值.c deleted file mode 100755 index e20423e..0000000 --- a/Test/C/程序设计基础I/实验3--while 循环结构程序设计/OJ3-9分段函数求值.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Description - - 有如下分段函数 - F(x) = x^2 + 1 当x> 0时; - F(x) = -x 当x<0时; - F(x) = 100.0 当x=0时; - 编程根据输入的不同x(x为实数),输出其对应的函数值 - Input - - 多组输入,每组一个实数x。处理到文件结束。 - Output - - 对于每组输入x,输出其对应的F(x),每组一行,结果保留1位小数。 - Sample - - Input - - 8.00 - -5.0 - Output - - 65.0 - 5.0 - - - */ -#include -int main () -{ - double x; - - while (scanf("%lf", &x) != EOF) - { - if (0 < x ) - { - x = x * x +1; - printf("%.1lf\n", x); - } - else if (0 > x) - { - x = -x; - printf("%.1lf\n", x); - } - else - { - x = 100; - printf("%.1lf\n", x); - } - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/A A+B for Input-Output Practice (II).c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/A A+B for Input-Output Practice (II).c deleted file mode 100755 index 37f9d2f..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/A A+B for Input-Output Practice (II).c +++ /dev/null @@ -1,36 +0,0 @@ -/* - Description - - Your task is to Calculate a + b. - Input - - Your task is to Calculate a + b. - Output - - For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. - Sample - - Input - - 2 - 1 5 - 10 20 - Output - - 6 - 30 - */ -#include -int main() -{ - int a, b, sum, i; - - for (scanf("%d", &i); scanf("%d %d", &a, &b)!=EOF; i--) - { - sum = a+b; - printf("%d\n", sum); - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/G 简单计算.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/G 简单计算.c deleted file mode 100755 index 4e28f23..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/G 简单计算.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - Description - - 接受从键盘输入的N个整数,输出其中的最大值、最小值和平均值(平均值为整除的商)。 - - Input - - 第一行一个正整数N(N<=100); - 第二行有N个用空格隔开的整数Ti (1 <= i <= N, 0 <= Ti <= 10000000) - Output - - 三个有空格隔开的整数分别为最大值、最小值和平均值,其中平均值为整除的商。 - Sample - - Input - - 5 - 1 2 3 5 4 - Output - - 5 1 3 - */ -#include -int main() -{ - int n=0; - long long int max=0,min=10000000,sum=0,num=0,average; - int i=1; - scanf("%d",&n); - for(i=1;i<=n;i++) - { - scanf("%lld",&num); - if(num>max) - max=num; - if(min>num) - min=num; - sum=sum + num; - } - average=sum/n; - printf("%lld %lld %lld",max,min,average); - return 0; - -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/H C:C++训练1---最大公约数与最小公倍数.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/H C:C++训练1---最大公约数与最小公倍数.c deleted file mode 100755 index 24fac3b..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/H C:C++训练1---最大公约数与最小公倍数.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - Description - - 输入两个正整数,求它们的最大公约数与最小公倍数。 - Input - - 输入两个正整数,两个整数之间用空格分开。 - - 数据保证在 int 范围内。 - Output - - 第一行输出最大公约数; - 第二行输出最小公倍数。 - - 答案保证在 int 范围内。 - Sample - - Input - - 64 48 - Output - - 16 - 192 - */ -#include -int main() -{ - int a,b,i,temp; - int max,min; - - scanf("%d %d",&a, &b); - if (b>a) - { - temp=a; - a=b; - b=temp; - } - else - { - a=a; - b=b; - } - i=a; - while(i>0)//最大公因数 - { - if ((a%i==0)&&(b%i==0)) - { -// printf("%d\n",i); - min=i; - break; - } - else - i--; - } - //最小公倍数是两数乘积除以最大公约数 - max=a*b/min; - printf("%d\n%d\n",min, max); - return 0; -} - diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/I C语言实验——判断素数(循环结构).c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/I C语言实验——判断素数(循环结构).c deleted file mode 100755 index 9f9b9b0..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/I C语言实验——判断素数(循环结构).c +++ /dev/null @@ -1,61 +0,0 @@ -/* - Description - - 从键盘上输入任意一个正整数,然后判断该数是否为素数。 - 如果是素数则输出"This is a prime." - 否则输出“This is not a prime.” - Input - - 输入任意一个正整数n(1 <= n <= 1000000)。 - Output - - 判断n是否为素数,并输出判断结果: - 如果n是素数则输出"This is a prime." - 否则输出“This is not a prime.” - - 特别提醒:请注意对1的判定,1不是素数。 - Sample - - Input - - 3 - Output - - This is a prime. - */ -#include -int main() -{ - int a,i,b,c=0; - scanf("%d",&a); - if (1==a) - { - printf("This is not a prime.\n"); - } - else - { - for (i=2; i -int main() -{ - int n=0,t = 0; - int max = 0,num=0,temp = 0; - int i=1; - scanf("%d",&n); - for(i=1;i<=n;i++) - { - scanf("%d",&num); - if (num<0) - { - temp=-num; - } - else - { - temp=num; - } - if(temp>max) - { - max=temp; - t=num; - } - } - printf("%d\n",t); - return 0; - -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/K C语言实验——圆周率.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/K C语言实验——圆周率.c deleted file mode 100755 index 5c55269..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/K C语言实验——圆周率.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - Description - - 输入n值,并利用下列格里高里公式计算并输出圆周率: - - Input - - 输入公式中的n值。 - Output - - 输出圆周率,保留5位小数。 - Sample - - Input - - 1 - Output - - 2.66667 - */ - -#include -int main() -{ - int n = 0,i; - double pi = 0.0; - - scanf("%d",&n); - - for (i=1; i<=n; i++) - { - pi=pi+(1.0/(4*i-3)); - pi=pi-(1.0/(4*i-1)); - } - printf("%.5lf\n",4*pi); - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/L 小鑫の日常系列故事(五)——卡片游戏.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/L 小鑫の日常系列故事(五)——卡片游戏.c deleted file mode 100755 index ac7bbf3..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/L 小鑫の日常系列故事(五)——卡片游戏.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - Description - - 小狗对小猫说:你猜猜我的口袋里有几块糖?小猫说:猜对了你给我吃吗?小狗点点头:嗯,猜对了两块都给你!小猫咽了咽口水说:我猜五块!然后,小狗笑着把糖放到小猫手里,说:我还欠你三块。 - 既然小猫这么喜欢吃糖,小狗决定每天都给小猫几块糖,但是呢,不能每天都给相同块数的糖,那样就太单调了。于是,第一天小狗给小猫1*1=1块,第二天2*2=4块……第 n 天给的糖数为 n*n 。现在已知小狗家共有 N 块糖,你需要帮他计算下这些糖最多可以给小猫几天? - Input - - 输入只有一个整数 N (0 <= N <= 10000)。 - Output - - 输出对应的天数。 - Sample - - Input - - 15 - Output - - 3 - */ -#include -int main() -{ - int - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/M 猜糖块.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/M 猜糖块.c deleted file mode 100755 index bcbdb13..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/M 猜糖块.c +++ /dev/null @@ -1,43 +0,0 @@ -/* -Description - - 小狗对小猫说:你猜猜我的口袋里有几块糖?小猫说:猜对了你给我吃吗?小狗点点头:嗯,猜对了两块都给你!小猫咽了咽口水说:我猜五块!然后,小狗笑着把糖放到小猫手里,说:我还欠你三块。 - 既然小猫这么喜欢吃糖,小狗决定每天都给小猫几块糖,但是呢,不能每天都给相同块数的糖,那样就太单调了。于是,第一天小狗给小猫1*1=1块,第二天2*2=4块……第 n 天给的糖数为 n*n 。现在已知小狗家共有 N 块糖,你需要帮他计算下这些糖最多可以给小猫几天? -Input - -输入只有一个整数 N (0 <= N <= 10000)。 -Output - -输出对应的天数。 -Sample - -Input - -15 -Output - -3 -*/ -#include -int main() -{ - int n,i,sum,d=0; - - scanf("%d",&n); - - for (i=1;n>0; i++) - { - sum=i*i; - n=n-sum; - if (n<0) - { - break; - } - d=d+1; - - - } - printf("%d\n",d); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/N C语言实验——分数序列.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/N C语言实验——分数序列.c deleted file mode 100755 index f769029..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/N C语言实验——分数序列.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - Description - - 有一个分数序列:2/1, 3/2, 5/3, 8/5, 13/8, …编写程序求出这个序列的前n项之和。 - Input - - 输入只有一个正整数n,1≤n≤10。 - Output - - 输出该序列前n项和,结果保留小数后6位。 - Sample - - Input - - 3 - Output - - 5.166667 - */ -#include -int main() -{ - int x=1,y=2,n = 0,i,t; - double sum=0.0; - - scanf("%d", &n); - - for (i=0; i -int main() -{ - int i,na = 0,nb = 0,nc = 0,nd = 0 ,ne= 0 ,mark = 0; - - - - for (scanf("%d",&i); i>0; i--) - { - scanf("%d",&mark); - if (mark>=90) - { - na++; - } - else if(mark>=80) - { - nb++; - } - else if(mark>=70) - { - nc++; - } - - else if(mark>=60) - { - nd++; - } - - else - { - ne++; - } - - } - - printf("A %d\nB %d\nC %d\nD %d\nE %d\n",na,nb,nc,nd,ne); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-1A+B for Input-Output Practice (II).c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-1A+B for Input-Output Practice (II).c deleted file mode 100755 index 265ff34..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-1A+B for Input-Output Practice (II).c +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Description - - Your task is to Calculate a + b. - Input - - Your task is to Calculate a + b. - Output - - For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input. - - Sample - - Input - - 2 - 1 5 - 10 20 - Output - - 6 - 30 - - */ -#include -int main() -{ - int a, b, n, sum; - - for (scanf("%d", &n); n > 0; n--) - { - scanf("%d %d", &a, &b); - sum = a + b; - printf("%d\n", sum); - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-2C语言实验——计算1到n的和(循环结构).c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-2C语言实验——计算1到n的和(循环结构).c deleted file mode 100755 index a450c83..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-2C语言实验——计算1到n的和(循环结构).c +++ /dev/null @@ -1,36 +0,0 @@ -/* - - Description - - 从键盘上输入任意一个整数n,计算1到n的和。 - Input - - 从键盘输入任意整数n。 - Output - - 输出1到n的和。 - Sample - - Input - - 3 - Output - - 6 - - */ -#include -int main () -{ - int n, sum; - - scanf("%d", &n); - - for (sum = 0; n > 0; n--) - { - sum = sum + n; - } - printf("%d\n", sum); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-3C语言实验——求阶乘(循环结构).c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-3C语言实验——求阶乘(循环结构).c deleted file mode 100755 index 1869e6f..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-3C语言实验——求阶乘(循环结构).c +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Description - - 从键盘输入任意一个大于等于0的整数n,然后计算n的阶乘,并把它输出。 - - 提示: 0!是 1 。 - Input - - 输入任意一个大于等于0的整数n。 - Output - - 输出n! - Sample - - Input - - 3 - Output - - 6 - - */ -#include -int main () -{ - int n, count; - - scanf("%d", &n); - - if (n != 0 && n > 0) - { - for (count = 1; n > 0; n--) - { - count = count * n; - } - printf("%d\n", count); - } - else if (0 == n) - { - printf("1\n"); - } - else - return 0; - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-4C语言实验——两个数比较.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-4C语言实验——两个数比较.c deleted file mode 100755 index 96c7af2..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-4C语言实验——两个数比较.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - Description - - 求2个数中较大者。 - Input - - 第一行为测试的数据组数N,接下来的N行分别是两个待比较的整数。 - Output - - 输出N行,每一行的值为每组数中较大的整数。 - Sample - - Input - - 2 - 1 2 - 15 10 - Output - - 2 - 15 - */ -#include -int main () -{ - int n, a, b; - - for (scanf("%d", &n); 0b) - { - printf("%d\n", a); - } - else - { - printf("%d\n", b); - } - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-5做乘法.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-5做乘法.c deleted file mode 100755 index 2af834b..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-5做乘法.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - - Description - - 请用C语言编写一个程序。此程序接收一个正整数N,然后打印输出“N次N*(1->N)格式”的数据。例如:此程序接收正整数5,那会输出以下格式的数据: - 5*1=5 - 5*2=10 - 5*3=15 - 5*4=20 - 5*5=25 - - Input - - 只有一个正整数N(N<=100)。 - Output - - - 输出共N行数据,如上面的例子所示。 - Sample - - Input - - 5 - Output - - 5*1=5 - 5*2=10 - 5*3=15 - 5*4=20 - 5*5=25 - */ -#include -int main() -{ - int sum=1,i, n; - - scanf("%d",&n); - - for (i=1; n>=i; i++) - { - sum = n*i; - printf("%d\*%d\=%d\n", n, i, sum); - - } - return 0; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/* -#include -int main() -{ - int n; - int i; - int y; - scanf("%d",&n); - for(i = 1; i <= n; i++) - { - y = n * i; - printf("%d*%d=%d\n",n,i,y); - } - return 0; -} - -*/ diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-6数列求和.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-6数列求和.c deleted file mode 100755 index 5c55c97..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/OJ4-6数列求和.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - - Description - - 数列求和是一类常见的问题,本题有一定的代表性: - 求s=a+aa+aaa+aaaa+……+aa…aa(n位) - 其中,a的值由键盘输入,位数n也由键盘输入。 - Input - - 第一行输入a的值; - 第二行输入位数n。 - Output - - 输出对n个数完成求和运算后的结果。 - 比如a=3,n=6时,s=3+33+333+3333+33333+333333 - Sample - - Input - - 3 - 6 - Output - - 370368 - */ -#include -int main () -{ - int a, n, c; - int s = 0, i = 0; - scanf ("%d", &a); - scanf("%d", &n); - - for (c=a; i -#include -int main() -{ - int T,i,n,m,s,k,t; - scanf("%d",&T); - while(T--) - { - s=0; - scanf("%d %d",&n,&m); - if(m -int main() -{ - int n,i,t,t2,clock; - scanf("%d",&n); - t=n; - t2=1; - clock=2*n-1; - while (clock!=n-1) - { - for (i=t-1;i>0; i--) - { - printf(" "); - } - for (i=t2; i>0; i--) - { - printf("*"); - } - printf("\n"); - - - t=t-1; - t2=t2+2; - clock--; - } - t=2*n-2; - t2=1; - while (clock!=0) - { - for (i=t2; i>0; i--) - { - printf(" "); - } - for (i=t;i!=0; i--) - { - printf("*"); - } - - printf("\n"); - - - t=t-1; - t2++; - clock--; - } - return 0; -} -*/ -#include -int main() -{ - int n,i,j; - scanf("%d",&n); - for(i=1;i<=n;i++) - { - for(j=1;j<=n-i;j++) - printf(" "); - for(j=1;j<=i;j++) - printf("*"); - for(j=1;j0;i--) - { - for(j=1;j<=n-i;j++) - printf(" "); - for(j=1;j<=i;j++) - printf("*"); - for(j=i-1;j>0;j--) - printf("*"); - printf("\n"); - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/R 水仙花数.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/R 水仙花数.c deleted file mode 100755 index 4a5ca1c..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/R 水仙花数.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Description - - 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,是这样定义的: - “水仙花数”是指一个三位数,它的各位数字的立方和等于其本身,比如:153=13+53+33。 - 现在要求输出所有在m和n范围内的水仙花数。 - Input - - 输入数据有多组,每组占一行,包括两个整数m和n(100<=m<=n<=999)。 - Output - - 对于每个测试实例,要求输出所有在给定范围内的水仙花数,就是说,输出的水仙花数必须大于等于m,并且小于等于n,如果有多个,则要求从小到大排列在一行内输出,之间用一个空格隔开; - 如果给定的范围内不存在水仙花数,则输出no; - 每个测试实例的输出占一行。 - Sample - - Input - - 100 120 - 300 380 - Output - - no - 370 371 -*/ -#include -int main () -{ - int m,n,n1,n2,t,i,sum=0,judge=0,t2,i2; - while (scanf("%d %d",&m, &n)!=EOF) - { - t2=0; - if(m>n) - { - t=n; - n=m; - m=t; - } - - for (i=m; i<=n; i++)//求范围内水仙花数 - { - for (i2=3,t=i; i2>0; i2--)//循环取数求立方和 - { - n1=t%10; - n2=n1*n1*n1; - - sum=sum+n2; - - t=t/10; - } - - if (sum==i) - { - if (t2==0) - { - printf("%d",i);//输出第一个水仙花数 - } - else - { - printf(" %d",i);//输出非第一个数 - } - t2++; - judge++; - sum=0;//sum初始化 - } - else - { - sum=0; - } - } - if (judge==0) - { - printf("no"); - } - printf("\n");//换行 - } - return 0; -} - diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/S C语言实验——余弦.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/S C语言实验——余弦.c deleted file mode 100755 index 6b69c0f..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/S C语言实验——余弦.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -int main() -{ - double x, sum, t, item; - int n, i; - while (scanf("%lf %d", &x, &n)==2) - { - t = x*x; - item = 1.0; - sum = 1.0; - for (i=1; i<=n; i++) - { - item *= -t; - item /= (i*2-1)*(i*2); - sum += item; - } - printf("%.4lf\n", sum); - } - return 0; -} - diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/T 完美的素数.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/T 完美的素数.c deleted file mode 100755 index fcd1bd2..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/T 完美的素数.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - Description - - 素数又称质数。指一个大于1的自然数,除了1和此整数自身外,不能被其他自然数整除的数。我们定义:如果一个素数是完美的素数,当且仅当它的每一位数字之和也是一个素数。现在给你一个正整数,你需要写个程序判断一下这个数按照上面的定义是不是一个完美的素数。 - Input - - 输入包含多组测试数据。 - 每组测试数据只包含一个正整数 n (1 < n <= 10^6)。 - Output - - 对于每组测试数据,如果 n 是完美的素数,输出“YES”,否则输出“NO”(输出均不含引号)。 - Sample - - Input - - 11 - 13 - Output - - YES - NO - */ -#include -int main() -{ - long long int n,temp = 0,sum=0,i; - - while (scanf("%lld",&n)!=EOF) - { - if(n==1||n==2) - { - printf("YES\n"); - continue; - } - temp=0; - sum=0; - if(n>10) - { - temp=n; - while (temp>0) - { - sum=sum+temp%10; - temp=temp/10; - } - } - else - sum=n; - - for (i=2; i - -int main() -{ - int n,i,sum,x; - while(scanf("%d",&n)!=EOF&&n) - { - sum=0; - for(i=0; i -int main() -{ - int a,sum=0,i,n,m,sum2=0; - while (scanf("%d %d",&n,&m)!=EOF) - { - sum=0; - sum2=0; - for (i = 0; i <= n; i++) - { - sum = sum + i; - } - - for (i = 0; i <= m; i++) - { - sum2 = sum2 + i; - } - - printf("%d\n", sum - sum2); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/W - C:C++练习7---求某个范围内的所有素数.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/W - C:C++练习7---求某个范围内的所有素数.c deleted file mode 100755 index 5840193..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/W - C:C++练习7---求某个范围内的所有素数.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -int main() -{ - int n,flag,i,i2,count = 0; - - scanf("%d",&n); - - for (i=2; i -int main() -{ - int n,i,i2,mu,flag=0; - - while (scanf("%d",&n)!=EOF) - for (i=1;i<=n;i++) - { - flag=0; - for (i2=1;i2<=i;i2++) - { - mu=i*i2; - if (flag==0) - printf("%d*%d=%d",i2,i,mu); - else - printf(" %d*%d=%d",i2,i,mu); - flag++; - - } - printf("\n"); - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验4--for循环结构程序设计/Y 区域内点的个数.c b/Test/C/程序设计基础I/实验4--for循环结构程序设计/Y 区域内点的个数.c deleted file mode 100755 index 265acca..0000000 --- a/Test/C/程序设计基础I/实验4--for循环结构程序设计/Y 区域内点的个数.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - Description - -X晚上睡不着的时候不喜欢玩手机,也不喜欢打游戏,他喜欢数星星。 -Input - - 多组输入。 - -每组先输入一个整数N(N <= 10000),接着输入两个点代表矩形的左下点B(x,y)和右上点T(x,y),然后输入N个(X,Y)代表N颗星星。问有多少颗星星在窗子内部,在窗边上的不计。 -Output - - 输出一个整数,代表有多少颗星星在窗子内部。 -Sample - -Input - -3 -0 1 -3 4 -1 1 -2 2 -3 3 -2 -1 1 -5 5 -4 4 -0 6 -Output - -1 -1 -*/ -#include -int main() -{ - int n,sum,i,x2,y2,x0,y0,x1,y1,temp; - - while (scanf("%d",&n)!=EOF) - { - scanf("%d %d",&x0,&y0); - scanf("%d %d",&x1,&y1); - - if(x0>x1) - { - temp=x0; - x0=x1; - x1=temp; - } - if(y0>y1) - { - temp=y1; - y0=y1; - y1=temp; - } - - sum=0; - for(i=0;ix0)&&(y2y0)) - { - sum++; - } - } - printf("%d\n",sum); - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/A - C语言实验——最值.c b/Test/C/程序设计基础I/实验5-一维数组/A - C语言实验——最值.c deleted file mode 100755 index 5712c02..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/A - C语言实验——最值.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - Description - - 有一个长度为n的整数序列,其中最大值和最小值不会出现在序列的第一和最后一个位置。 - 请写一个程序,把序列中的最小值与第一个数交换,最大值与最后一个数交换。输出转换好的序列。 - Input - - 输入包括两行。 - 第一行为正整数n(1≤n≤10)。 - 第二行为n个正整数组成的序列。 - Output - - 输出转换好的序列。数据之间用空格隔开。 - Sample - - Input - - 6 - 2 3 8 1 4 5 - Output - - 1 3 5 2 4 8 - */ -#include -int main() -{ - int n,i,t=0,t2=65535,temp,ima=0,imi=0; - - scanf("%d",&n); - - int a[n]; - - for(i=0;i=t)//最大 - { - t=a[i]; - ima=i; - } - - if(a[i]<=t2)//最小 - { - t2=a[i]; - imi=i; - } - } - - temp=a[0]; - a[0]=a[imi]; - a[imi]=temp; - - temp=a[n-1]; - a[n-1]=a[ima]; - a[ima]=temp; - - for (i=0;i -int main() -{ - long int a,n; - int i=0,count=0; - - scanf("%ld",&a); - - n=a; - - while (n>0) - { - n=n/10; - count++; - } - - int num[count]; - - n=a; - - while (n>0) - { - num[i]=n%10; - i++; - n=n/10; - } - - printf("%d\n",count); - - for(i=count-1;i>=0;i--) - { - if (i==count-1) - printf("%d",num[count-1]); - else - printf(" %d",num[i]); - } - - printf("\n"); - - for(i=0;i -int main() -{ - int nmax,nmin,ave,n,i,sum,count; - - while (scanf("%d",&n)!=EOF) - { - nmax = 0; - nmin = 0; - sum=0; - count=0; - - int a[n]; - - for (i = 0; i < n; i++) - { - scanf("%d", &a[i]); - sum = sum + a[i]; - } - - ave = sum / n; - - for (i = 0; i < n; i++) - { - if (a[i] > ave) - nmax++; - if (a[i]==ave) - count++; - if (a[i] -int main() -{ - int n=0, sum=0, l, r, i; - - scanf("%d", &n); - - int a[n]; - - for (i = 0; i < n; i++) - { - scanf("%d", &a[i]); - } - - scanf("%d %d", &l, &r); - - for (i = l-1; i < r; i++) - { - sum = sum + a[i]; - - } - - printf("%d\n",sum); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/E C语言实验——分割整数.c b/Test/C/程序设计基础I/实验5-一维数组/E C语言实验——分割整数.c deleted file mode 100755 index dadfadc..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/E C语言实验——分割整数.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - Description - - 从键盘输入一个长整数(不超过10位),从高位开始逐位分割并输出。 - Input - - 正整数n,不含前导零。 - Output - - 分割的整数序列,各整数之间用空格格开。 - 注意,最后一个数字后面没有空格! - Sample - - Input - - 678123 - Output - - 6 7 8 1 2 3 - */ -#include -int main() -{ - long long int num,sum=0,n,i=0; - - scanf("%lld",&num); - - n=num; - - while (n>0) - { - n=n/10; - sum++; - } - - int a[sum]; - - for(i=0;i=0;i--) - { - if (i==sum-1) - { - printf("%d",a[sum-1]); - } - else - { - printf(" %d",a[i]); - } - } - - printf("\n"); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/F 众数.c b/Test/C/程序设计基础I/实验5-一维数组/F 众数.c deleted file mode 100755 index 638f920..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/F 众数.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - Description - - - - 给定一个由 n 个整数组成的序列A1,A2,……, An 和两个整数L,R,你的任务是写一个程序来计算序列号在[L,R](这是一个闭区间) 这段位置区间内所有数的总和。 - - - Input - - - - 输入只有一组测试数据: - - 测试数据的第一行为一个整数 n (1< n < 10000); - - 第二行为 n 个 int 类型的整数; - - 第三行为两个整数 L,R(0 < L < R <= n)。 - Output - - - - 输出序列号在区间[L,R]内所有数的和,数据保证和在 int 类型范围内。 - Sample - - Input - - 5 - 3 5 6 2 9 - 2 4 - Output - - 13 - */ -/*TLE - #include -int main() -{ - int n,i,i2,count=0,judge=50; - while ((scanf("%d",&n)!=EOF)||(judge!=0)) - { - - int a[n], c[n]; - - for (i = 0; i < n; i++) - { - scanf("%d", &a[i]); - } - - for (i = 0; i < n; i++) - { - for (i2 = 0; i2 < n; i2++) - { - if (a[i] == a[i2]) - { - count++; - } - } - c[i] = count; - count = 0; - } - - i2 = 0; - - for (i = 1; i < n; i++) - { - if (c[i - 1] > c[i]) - { - i2 = i-1; - } - else - { - i2 = i; - } - } - printf("%d\n", a[i2]); - judge--; - - } - return 0; -} -*/ -#include -int main() -{ - int a,n; - int i,k; - while(~scanf("%d",&n)) - { - int b[1001]={0},max=0; - for(i=0;imax) - { - max = b[i]; - k = i; //标记其下标; - } - } - printf("%d\n",k); - } - return 0; -} - - diff --git a/Test/C/程序设计基础I/实验5-一维数组/G 小鑫爱运动.c b/Test/C/程序设计基础I/实验5-一维数组/G 小鑫爱运动.c deleted file mode 100755 index 5898b90..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/G 小鑫爱运动.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - Description - 小鑫非常喜欢运动,有一次小鑫去参加110米栏的比赛,一共有10名比赛选手,小鑫是1号,由于跑的太专注,最后冲线的时候不知道自己是第几名,只知道每个人最后的成绩,聪明的你可不可以帮帮他? - - Input - 多组输入。 - - 先输入一个10, - 然后每组输入10个整数,代表10个选手的110米栏成绩m,代表1号到N号的N个选手的成绩m,m范围是(0 < m < 100)。 - - Output - 输出只有一行,代表小鑫最后的名次是多少。 - - 因为小鑫长得丑,成绩相同时,他总是排在前面。 - - - - Sample - Input - 10 - 2 5 3 9 7 10 23 12 43 5 - 10 - 6 1 7 9 3 4 8 3 2 9 - Output - 1 - 6 - */ -#include -int main() -{ - int n, a[10], i, i2, num = 1; - while (scanf("%d", &n) != EOF) - { - for (i = 0; i < 10; i++) - { - scanf("%d", &a[i]); - } - for (i = 1; i < 10; i++) - { - if (a[0] > a[i]) - { - num++; - } - } - printf("%d\n", num); - num = 1; - } - - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/H - C语言实验——数日子.c b/Test/C/程序设计基础I/实验5-一维数组/H - C语言实验——数日子.c deleted file mode 100755 index 5ed3a4e..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/H - C语言实验——数日子.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - Description - - 光阴似箭,日月如梭,大学的时间真是宝贵,要抓紧时间AC^_^。你知道今天是这一年第几天吗,掐指一算还是要算好久,呵呵还是让计算机来做吧。这里的问题就是让你来写一个程序,输入某年某月某日,判断这一天是这一年的第几天? - Input - - 输入第一行是数据的组数n<100,下面n行是n组数据,每组数据由3个正整数组成,分别为年、月、日,我们保证每组数据都是有效的日期。 - Output - - 输出所输入的日期是这一年的第几天。 - Sample - - Input - - 2 - 2009 1 1 - 2008 1 3 - Output - - 1 - 3 - */ -#include -int main() -{ - int i,n; - - int y,m,d,sum,i2; - - - while(scanf("%d",&n)!=EOF) - { - for(i=0;i -#include -int main() -{ - long int j,n,len ; - char str[100],t,le[5]; - - scanf("%ld",&n); - - while(n>0) - { - memset(str,0,sizeof(str)); - memset(le,0,sizeof(le)); - - gets(str); - - len = strlen(str); - - for(j=0;j='A'&&t<='Z') - str[j]=str[j]+32; - t=str[j]; - switch (t) - { - case 'a': - le[0]++; - break; - case 'e': - le[1]++; - break; - case 'i': - le[2]++; - break; - case 'o': - le[3]++; - break; - case 'u': - le[4]++; - break; - - } - } - - printf("a:%d\n",le[0]); - printf("e:%d\n",le[1]); - printf("i:%d\n",le[2]); - printf("o:%d\n",le[3]); - printf("u:%d\n",le[4]); - - n--; - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/I - 喵帕斯之平地摔.c b/Test/C/程序设计基础I/实验5-一维数组/I - 喵帕斯之平地摔.c deleted file mode 100755 index 751229f..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/I - 喵帕斯之平地摔.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -int main () -{ -int n,i,a,sum=0,i2; - -while(scanf("%d",&n)!=EOF) -{ - int a[n]; - for(i=0;i1)||((i+1)a[i+1])&&(a[i]>a[i-1])) - { - sum++; - } - } - - } - printf("%d\n",sum); - sum=0; -} -return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/J - 排序.c b/Test/C/程序设计基础I/实验5-一维数组/J - 排序.c deleted file mode 100755 index a42b9b0..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/J - 排序.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - Description - - 给你N(N<=100)个数,请你按照从小到大的顺序输出。 - Input - - 输入数据第一行是一个正整数N,第二行有N个整数。 - Output - - 输出一行,从小到大输出这N个数,中间用空格隔开。 - Sample - - Input - - 5 - 1 4 3 2 5 - Output - - 1 2 3 4 5 - */ -#include -int main() -{ - int n,i,t; - - scanf("%d",&n); - - int a[n]; - - for (i=0; i a[i+1]) - { - t = a[i]; - a[i] = a[i+1]; - a[i+1] = t; - i=0; - continue; - } - } - - if(a[0] > a[1]) - { - t = a[0]; - a[0] = a[1]; - a[1] = t; - } - - for (i=0; i -int main() -{ - int n,i,t,j; - - scanf("%d",&n); - - int a[n]; - - for (i=0; i a[j+1]) - { - t = a[j]; - a[j] = a[j+1]; - a[j+1] = t; - } - } - - } - - for (i=0; i -int main() -{ - int n,i,t,j; - - scanf("%d",&n); - - int a[n]; - - for (i=0; i a[j+1]) - { - t = a[j]; - a[j] = a[j+1]; - a[j+1] = t; - } - } - - } - - for (i=0; i -int main() -{ - int i,t,j; - int n=10; - int a[10],c[10]; - - for (i=0; i a[j+1]) - { - t = a[j]; - a[j] = a[j+1]; - a[j+1] = t; - - t = c[j]; - c[j] = c[j+1]; - c[j+1] = t; - - } - } - - } - - for (i=0; i -int main() -{ - int i,t,j; - int n=10; - int a[10],c[10]; - - for (i=0; i a[j+1]) - { - t = a[j]; - a[j] = a[j+1]; - a[j+1] = t; - - t = c[j]; - c[j] = c[j+1]; - c[j+1] = t; - - } - } - - } - - for (i=0; i -int main() -{ - int i,j,t,n; - - double m; - - while (scanf("%d",&n)!=EOF) - { - int a[n]; - - for (i=0; i a[j+1]) - { - t = a[j]; - a[j] = a[j+1]; - a[j+1] = t; - } - } - - } - - if (n%2==0) - { - m=(double)(a[(n/2)-1]+a[(n/2)])/2; - printf("%.1lf",m); - } - else - { - m=a[(n+1)/2-1]; - printf("%.1lf",m); - } - printf("\n"); - - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/N C语言实验——各位数字之和排序.c b/Test/C/程序设计基础I/实验5-一维数组/N C语言实验——各位数字之和排序.c deleted file mode 100755 index 11d3e73..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/N C语言实验——各位数字之和排序.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Description - 给定n个正整数,根据各位数字之和从小到大进行排序。 - - Input - 输入数据有多组,每组数据占一行,每行的第一个数正整数n,表示整数个数,后面接n个正整数。当n为0时,不作任何处理,输入结束。n<=10 - - Output - 输出每组排序的结果。 - - Sample - Input - 3 230 59 110 - 5 199 220 108 235 120 - 0 - Output - 110 230 59 - 120 220 108 235 199 - */ -#include -int main() { - int i, j, t, n, sum,temp; - - double m; - - while (scanf("%d", &n)!=EOF&&n) - { - - int a[n], num[n]; - - for (i = 0; i < n; i++) - { - scanf("%d", &num[i]); - } - - for (i = 0; i < n; i++) - { - sum = 0; - temp = num[i]; - while (temp > 0) - { - sum = sum + temp % 10; - - temp = temp / 10; - } - a[i] = sum; - } - - for (i = 0; i < n - 1; i++) - { - for (j = 0; j < n - 1 - i; j++) - { - if (a[j] > a[j + 1]) - { - t = a[j]; - a[j] = a[j + 1]; - a[j + 1] = t; - - t = num[j]; - num[j] = num[j + 1]; - num[j + 1] = t; - } - } - - } - - for (i = 0; i < n; i++) - { - if (i == 0) - printf("%d", num[0]); - else - printf(" %d", num[i]); - } - - printf("\n"); - - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/O 期末考试之排名次.c b/Test/C/程序设计基础I/实验5-一维数组/O 期末考试之排名次.c deleted file mode 100755 index 7fc948e..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/O 期末考试之排名次.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - Description - 期末考试结束了,童鞋们的成绩也出来的了,可是为了排名次可忙坏了老师,因为学生太多了。这时,老师把这个任务交给了你,希望你能帮老师完成。作为IT人,你当然不能用笨笨的人工方法了,编程解决才是好办法。 - 共有三门课,语文、数学和英语,要求根据学生的各科成绩计算出其总成绩,并根据总成绩从高到低排序。 - - Input - 第一行一个整数N(N<=100),代表学生的人数。 - 接下来的N行数据,每行有三个整数,C,M,E分别代表一个学生语文、数学和英语的成绩。 - Output - 一共N行,每行一个数,从大到小,分别代表各个学生的总成绩。 - Sample - Input - 3 - 70 80 90 - 59 59 59 - 100 100 100 - Output - 300 - 240 - 177 - */ diff --git a/Test/C/程序设计基础I/实验5-一维数组/P - 次大和次小.c b/Test/C/程序设计基础I/实验5-一维数组/P - 次大和次小.c deleted file mode 100755 index 8a3b7c1..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/P - 次大和次小.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - Description - - 对于一个数组,次大的数指数组中第二大的数,相似地,次小的数指数组中第二小的数。 - - 给定一个含有 n 个数的数组(数组中的数互不相同),求其中次大的数和次小的数。 - Input - - 首先输入一个整数 T (1 <= T <= 200),表示数据组数。 - - 对于每组数据: - 第 1 行输入一个整数 n (2 <= n <= 1000),表示数组中元素的数量。 - 第 2 行输入 n 个用空格隔开的整数 Ai (-10000 <= Ai <= 10000),表示数组中每一个元素的值。 - Output - - 对于每组数据,输出一行,包含 2 个整数 a, b,分别表示次大和次小的数。 - Sample - - Input - - 1 - 5 - 3 1 2 4 5 - Output - - 4 2 - */ -#include -int main() -{ - int n,i,j,t,T; - - scanf("%d",&T); - - while(T>0) - { - scanf("%d", &n); - - int a[n]; - - for (i = 0; i < n; i++) - { - scanf("%d", &a[i]); - } - - for (i = 0; i < n - 1; i++) - { - for (j = 0; j < n - 1 - i; j++) - { - if (a[j] < a[j + 1]) - { - t = a[j]; - a[j] = a[j + 1]; - a[j + 1] = t; - } - } - } - - printf("%d %d",a[1],a[n-2]); - printf("\n"); - T--; - } - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/Q - 冒泡排序中数据交换的次数.c b/Test/C/程序设计基础I/实验5-一维数组/Q - 冒泡排序中数据交换的次数.c deleted file mode 100755 index 4535575..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/Q - 冒泡排序中数据交换的次数.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - Description - - 听说过冒泡排序么?一种很暴力的排序方法。今天我们不希望你用它来排序,而是希望你能算出从小到大冒泡排序的过程中一共进行了多少次数据交换。 - Input - - 输入数据的第一行为一个正整数 T ,表示有 T 组测试数据。 - 接下来T行,每行第一个整数N, 然后有N个整数,无序。0 -int main() -{ - int n,i,j,t,count,T; - - scanf("%d", &T); - while (T>0) - { - scanf("%d",&n); - - int a[n]; - - for (i = 0; i < n; i++) - { - scanf("%d", &a[i]); - } - count=0; - for (i = 0; i < n - 1; i++) - { - for (j = 0; j < n - 1 - i; j++) - { - if (a[j] > a[j + 1]) - { - t = a[j]; - a[j] = a[j + 1]; - a[j + 1] = t; - count++; - } - } - } - - printf("%d\n",count); - T--; - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验5-一维数组/R - 小金追呀追不上妹子 .c b/Test/C/程序设计基础I/实验5-一维数组/R - 小金追呀追不上妹子 .c deleted file mode 100755 index e93845f..0000000 --- a/Test/C/程序设计基础I/实验5-一维数组/R - 小金追呀追不上妹子 .c +++ /dev/null @@ -1,57 +0,0 @@ -/* - Description - 众所周知,C语言的学习是我们程序设计基础的重点和主要内容。 - 小金知道他喜欢的妹子最喜欢的水果是苹果,但是小金是种玉米的哪!所以他为了讨好妹子的欢心,他会从收获的n个玉米中挑选出m个最大的玉米去抠脚大汉那里换苹果,问题是,他这m个玉米的价值有多大? - - Input - 多组输入。 - 每行开始输入两个整数分别为n,m。代表含义如题目所述。 - 接下来一行有n个整数,代表每个玉米的价值。 - 1 < = m < n < = 1000 - - Output - 输出小金m个最大玉米的总价值。 - 输出占一行,保证数据合法。 - - Sample - Input - 10 4 - 1 2 3 4 5 6 7 8 9 10 - 5 3 - 1 2 3 4 5 - */ -#include -int main() -{ - int n,i,j,t,m,sum; - - while (scanf("%d %d",&n,&m)!=EOF) - { - int a[n]; - sum=0; - for(i=0;i -int main() -{ - int n,m,t,i,t2,j; - - scanf("%d",&n); - - int a[n]; - - for(i=0;i 0; j--) - { - a[j] = a[j-1]; - } - a[0] = t; - } - - for (i=0; i -int main() -{ - int n,i,j,t; - - scanf("%d",&n); - int a[n]; - for(i=0;i 0; j--) - { - a[j] = a[j - 1]; - } - - a[0] = t; - - - for (j = 0; j < n; j++) - { - if(j==0) - printf("%d",a[j]); - else - printf(" %d",a[j]); - } - } - printf("\n"); - } - - - - return 0; -} diff --git a/Test/C/程序设计基础I/实验6-二维数组(未完)/A - C语言实验——求一个3*3矩阵对角线元素之和.c b/Test/C/程序设计基础I/实验6-二维数组(未完)/A - C语言实验——求一个3*3矩阵对角线元素之和.c deleted file mode 100755 index f2b42fa..0000000 --- a/Test/C/程序设计基础I/实验6-二维数组(未完)/A - C语言实验——求一个3*3矩阵对角线元素之和.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - Description - 给定一个3*3的矩阵,请你求出对角线元素之和。 - - Input - 按照行优先顺序输入一个3*3矩阵,每个矩阵元素均为整数。 - - Output - 从左下角到右上角这条对角线上的元素之和 - - Sample - Input - 1 2 3 - 3 4 5 - 6 0 1 - Output - 13 - */ -#include -int main() -{ - int i,j,sum=0; - int a[3][3]; - - for(i=0;i<3;i++) - { - for(j=0;j<3;j++) - { - scanf("%d", &a[i][j]); - } - } - - for(i=0,j=2;i<3;i++,j--) - { - sum=sum+a[i][j]; - } - - printf("%d",sum); - - return 0; -} diff --git a/Test/C/程序设计基础I/实验6-二维数组(未完)/B 爬山.c b/Test/C/程序设计基础I/实验6-二维数组(未完)/B 爬山.c deleted file mode 100755 index 9fe1207..0000000 --- a/Test/C/程序设计基础I/实验6-二维数组(未完)/B 爬山.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - Description - LeiQ最近参加了一个登山俱乐部,部长给他了一个n*m地图,地图上的每一个格子的值表示一个山的海拔高度,LeiQ现在在(x,y)表示在地图上的位置,他想要登上地图上最高的山,所以他想知道他爬上最高的山的山顶还需向上爬多少米。 - - 例如: - - - x\y - - 1 - - 2 - - 3 - - 1 - - 100 - - 130 - - 150 - - 2 - - 200 - - 300 - - 100 - - 3 - - 100 - - 150 - - 50 - - - - - - - - - - - - - - - 现在LeiQ在(2,1),则他的位置海拔高度为200米,最高的为300米,所以还需爬100米 - - Input - 多组输入 - 每组的第一行是两个整数n,m(1<=n,m<=100),表示地图的大小 - - 接下来n行,每行m个整数,表示山的海拔高度(0<=Hij<=1000) - - 最后一行两个整数x,y表示LeiQ的位置 - - Output - 输出他还需要向上爬多少米。 - - - - Sample - Input - 3 3 - 100 130 150 - 200 300 100 - 100 150 50 - 2 1 - Output - 100 - */ -#include -int main() -{ - int n,m,i,j,x,y,flag=0,c; - - while (scanf("%d %d",&n,&m)!=EOF) - { - flag=0; - int a[n][m]; - - for(i=0;i -int main() -{ - int n,j,i; - - int a[100][100]; - - scanf("%d",&n); - - for(i=0;i -int main() -{ - int n,i,j,flag=0; - - int a[20][20]; - - while (scanf("%d",&n)!=EOF&&n) - { - flag=0; - for(i=0;i -int main() -{ - int j,i,T,m,n,flag=1; - - int a[101][101]; - - scanf("%d",&T); - while(flag<=T) - { - scanf("%d %d",&m,&n); - for(i=0;i=0;j--) - { - if(j==m-1) - printf("%d",a[j][i]); - else - printf(" %d",a[j][i]); - } - printf("\n"); - } - flag++; - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/A - C语言实验——计算表达式.c b/Test/C/程序设计基础I/实验7-函数应用/A - C语言实验——计算表达式.c deleted file mode 100755 index 25d7d61..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/A - C语言实验——计算表达式.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -double f(int x,int n); -int main() -{ - int n,x; - - scanf("%d %d",&x,&n); - - printf("%.2lf\n",f(x,n)); - - return 0; -} -double f(int x,int n) -{ - int i; - double t=x; - - for(i=1;i<=n;i++) - { - t=sqrt((double)(i+t)); - } - - return t; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/B - 求数列的和.c b/Test/C/程序设计基础I/实验7-函数应用/B - 求数列的和.c deleted file mode 100755 index a5f4acf..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/B - 求数列的和.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -double f(int n,int m); -int main() -{ - - int n,m; - - while(~scanf("%d %d",&n,&m)) - { - printf("%.2lf\n",f(n,m)); - } - - return 0; -} - -double f(int n,int m) -{ - double j=n,i; - double sum=0; - - for(i=0;i -#include -void f(int a,int b,int c); -int main() -{ - int a,b,c; - - scanf("%d %d %d",&a,&b,&c); - - f(a,b,c); - - return 0; -} -void f(int a,int b,int c) -{ - double x1,x2,t; - - x1=(double)(-b+sqrt(b*b-4*a*c))/(2*a); - x2=(double)(-b-sqrt(b*b-4*a*c))/(2*a); - - if (x2>x1) - { - t=x2; - x2=x1; - x1=t; - } - printf("%.2lf %.2lf",x1,x2); -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/D - 求三角形面积.c b/Test/C/程序设计基础I/实验7-函数应用/D - 求三角形面积.c deleted file mode 100755 index 4cdf9d0..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/D - 求三角形面积.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - Description - 已知三角形的边长a、b和c,求其面积。 - - Input - 输入三边a、b、c。 - - Output - 输出面积,保留3位小数。 - - Sample - Input - 1 2 2.5 - Output - 0.950 - Hint - 海伦公式求三角形面积。如果三角形的三边为a, b, c且p=(a+b+c)/2,则三角形面积为(p*(p-a) * (p - b) * (p -c))的平方根。 - */ -#include -#include -double f(double a,double b,double c); -int main() -{ - double a,b,c; - - scanf("%lf %lf %lf",&a,&b,&c); - - printf("%.3lf",f(a,b,c)); - - return 0; -} - -double f(double a,double b,double c) -{ - double res,p; - - p=(a+b+c)/2; - - res=sqrt(p*(p-a) * (p - b) * (p -c)); - - return res; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/E - 求实数绝对值.c b/Test/C/程序设计基础I/实验7-函数应用/E - 求实数绝对值.c deleted file mode 100755 index d34ee6a..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/E - 求实数绝对值.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - Description - 求实数的绝对值。 - Input - 输入数据有多组,每组占一行,每行包含一个实数。输入文件直到EOF为止! - Output - 对于每组输入数据,输出它的绝对值,要求每组数据输出一行,结果保留两位小数。 - Sample - Input - 123 - -234.00 - Output - 123.00 - 234.00 - Hint - EOF结束的语句是这样使用的,今后还后很多这样的题目,千万要记住哦... - - while (scanf("%f",&a)!=EOF) - { } - - 如果输入数据有多组,每组占一行。 - - 每行有两个整数a和n,分别用空格分隔。 - - 读到文件结束的输入形式为: - - while (scanf("%d %d",&a,&n)!=EOF) - { } - */ -#include -#include -double f(double n); -int main() -{ - double n; - - while(~scanf("%lf",&n)) - { - printf("%.2lf\n",f(n)); - } - - return 0; -} - -double f(double n) -{ - if(n<0) - { - n=-n; - } - - return n; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/F - C:C++程序训练6---歌德巴赫猜想的证明 .c b/Test/C/程序设计基础I/实验7-函数应用/F - C:C++程序训练6---歌德巴赫猜想的证明 .c deleted file mode 100755 index 7b15fc5..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/F - C:C++程序训练6---歌德巴赫猜想的证明 .c +++ /dev/null @@ -1,67 +0,0 @@ -/* - Description - - 验证“每个不小于6的偶数都是两个素数之和”,输入一个不小于6的偶数n,找出两个素数,使它们的和为n。 - Input - - 输入一个不小于6的偶数n。 - Output - - 找出两个素数,使它们的和为n。只需要输出其中第一个素数最小的一组数据即可。 - Sample - - Input - - 80 - Output - - 80=7+73 - */ -#include -#include -void f(int n); -int main() -{ - int n; - - scanf("%d",&n); - - f(n); - - return 0; -} -void f(int n) -{ - int i,t,j,f=0; - - for(i=2;i -long long int f(long long int n); -int main() -{ - long long int n,m,t; - - while(scanf("%lld %lld",&n,&m)!=EOF) - { - t=f(n)/f(n-m); - printf("%lld %lld\n",t,t/f(m)); - } - - return 0; -} -long long int f(long long int n) -{ - long long int sum=1; - int i; - - for(i=1;i<=n;i++) - { - sum=sum*i; - } - return sum; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/H - 分段函数 .c b/Test/C/程序设计基础I/实验7-函数应用/H - 分段函数 .c deleted file mode 100755 index 6e8776b..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/H - 分段函数 .c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Description - 函数是一种特殊的映射,即数集到数集的映射。对于给定的每个自变量都能给出一个确定的值,这是一件多么牛的事情呀。其实不是函数牛,而是因为它具有这种性质我们的数学家才这么定义了它。函数有很多类型,虽然本质都是映射,但为了方便研究和应用,数学家们做了很多分类。比如线性函数,非线性函数,随机函数,还有一些具有特殊性质的函数等等。 - - 今天我们要关注的是分段函数,所谓分段就是对于整个定义域来说,函数的值域是不连续的。很明显的一个就是绝对值函数,类似于y=|x|,(x,y属于R)。不连续是按照自变量的连续变化函数值的变化不连续而已,但函数仍然不离不弃的给了每个自变量一个值。 - - 总之,函数就是按照规则对自变量进行操作得到相应的值。而程序里的函数就更牛了,它可以对我们的输入(自变量)进行各种我们想做的操作,最后得到输出(值),很好玩吧。 - - 今天,就希望你能用程序里的函数实现数学里的分段函数,加油哦。 - - 这个分段函数长得是这个样子的: - - F(x) = log2(x) 0=10 - - - - Input - 输入第一行给出数据的组数T。 - 接下来T行每行一个实数X。 - - - - Output - 输出T行,每行一个函数值,四舍五入保留到小数点后两位。 - 希望你能根据函数的表达式,对于给定的每个自变量不离不弃的计算出它的值。 - - - - Sample - Input - 4 - 0 - 10 - 5 - -1 - Output - 0.00 - 100.00 - 2.32 - 0.16 - Hint - log2(x)是以2为底x的对数. - */ -#include -#include -double f(double x); -int main() -{ - int T; - double x; - - scanf("%d",&T); - while(T--) - { - scanf("%lf",&x); - printf("%.2lf\n",f(x)); - } - return 0; -} - -double f(double x) -{ - double res; - - if (x>=10) - res=x*x; - else if(x==0) - res=0; - else if (x<0) - res=-x+sin(x); - else - res=log2(x); - - return res; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/I - C:C++经典程序训练2---斐波那契数列.c b/Test/C/程序设计基础I/实验7-函数应用/I - C:C++经典程序训练2---斐波那契数列.c deleted file mode 100755 index 3394d15..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/I - C:C++经典程序训练2---斐波那契数列.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - Description - 编写计算斐波那契(Fibonacci)数列的第n项函数fib(n)(n < 40)。 - 数列描述: - f1=f2==1; - fn=fn-1+fn-2(n>=3)。 - - Input - 输入整数 n 的值(0 < n < 40)。 - - Output - 输出fib(n)的值。 - - Sample - Input - 7 - Output - 13 - Hint - 注意第1项和第2项的输出处理 - */ -#include -int f(int n); -int main() -{ - int n; - scanf("%d",&n); - printf("%d\n",f(n)); - - return 0; -} -int f(int n) -{ - int res; - - if (n==1||n==2) - res=1; - else - res=f(n-1)+f(n-2); - - return res; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/J - 计算题.c b/Test/C/程序设计基础I/实验7-函数应用/J - 计算题.c deleted file mode 100755 index 3029b00..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/J - 计算题.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - Description - 一个简单的计算,你需要计算f(m,n),其定义如下: - 当m=1时,f(m,n)=n; - 当n=1时,f(m,n)=m; - 当m>1,n>1时,f(m,n)= f(m-1,n)+ f(m,n-1) - Input - 第一行包含一个整数T(1<=T<=100),表示下面的数据组数。 - 以下T行,其中每组数据有两个整数m,n(1<=m,n<=2000),中间用空格隔开。 - Output - 对每组输入数据,你需要计算出f(m,n),并输出。每个结果占一行。 - Sample - Input - 2 - 1 1 - 2 3 - Output - 1 - 7 - */ -#include -int f(int m,int n); -int main() -{ - int n,m,T; - scanf("%d",&T); - while(T--) - { - scanf("%d %d",&m,&n); - printf("%d\n",f(m,n)); - } - - return 0; -} -int f(int m,int n) -{ - int res; - - if (m==1) - res=n; - else if(n==1) - res=m; - else if(m>1&&n>1) - res=f(m-1,n)+f(m,n-1); - - return res; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/K - 斐波那契?.c b/Test/C/程序设计基础I/实验7-函数应用/K - 斐波那契?.c deleted file mode 100755 index f60a6de..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/K - 斐波那契?.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - Description - 给出一个数列的递推公式,希望你能计算出该数列的第N个数。递推公式如下: - - F(n)=F(n-1)+F(n-2)-F(n-3). 其中,F(1)=2, F(2)=3, F(3)=5. - - 很熟悉吧,可它貌似真的不是斐波那契数列呢,你能计算出来吗? - - Input - 输入只有一个正整数N(N>=4). - - Output - 输出只有一个整数F(N). - - Sample - Input - 5 - Output - 8 - */ -#include -int f(int n); -int main() -{ - int n; - - scanf("%d",&n); - - printf("%d\n",f(n)); - - return 0; -} - -int f(int n) -{ - int res; - - if (n==1) - res=2; - else if(n==2) - res=3; - else if(n==3) - res=5; - else if(n>=4) - res=f(n-1)+f(n-2)-f(n-3); - return res; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/L - 高中数学?.c b/Test/C/程序设计基础I/实验7-函数应用/L - 高中数学?.c deleted file mode 100755 index 36ccf9e..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/L - 高中数学?.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - - L - 高中数学? - Description - 高中数学大家都学过数列,其中一个重要的概念就是数列的通项,可以代表数列中每一项的一个表达式。 - 今天我们的问题就跟通项有关系,说,给你一个数列的通项和数列中的前几项,希望你能求出它的第n项。 - 通项表达式如下: - F(1) = 0; - F(2) = 1; - F(n) = 4*F(n-1)-5*F(n-2); - Input - 输入数据第一行是一个正整数T,T<100。接下来T行,每行一个整数n, 2 -int f(int n); -int main() -{ - int n,T; - - scanf("%d",&T); - while(T--) - { - scanf("%d",&n); - - printf("%d\n",f(n)); - } - - - return 0; -} - -int f(int n) -{ - int res; - - if (n==1) - res=0; - else if(n==2) - res=1; - else if(n>=3) - res=4*f(n-1)-5*f(n-2); - - return res; -} diff --git a/Test/C/程序设计基础I/实验7-函数应用/M - 计算组合数.c b/Test/C/程序设计基础I/实验7-函数应用/M - 计算组合数.c deleted file mode 100755 index b20e799..0000000 --- a/Test/C/程序设计基础I/实验7-函数应用/M - 计算组合数.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - Description - 计算组合数。C(n,m),表示从n个数中选择m个的组合数。 - 计算公式如下: - 若:m=0,C(n,m)=1 - 否则, 若 n=1,C(n,m)=1 - 否则,若m=n,C(n,m)=1 - 否则 C(n,m) = C(n-1,m-1) + C(n-1,m). - - - - Input - 第一行是正整数N,表示有N组要求的组合数。接下来N行,每行两个整数n,m (0 <= m <= n <= 20)。 - - Output - 输出N行。每行输出一个整数表示C(n,m)。 - Sample - Input - 3 - 2 1 - 3 2 - 4 0 - Output - 2 - 3 - 1 - */ -#include -#include -int c(int n,int m); -int main() -{ - int t,m,n; - - scanf("%d",&t); - - while(t--) - { - scanf("%d %d",&n, &m); - printf("%d\n",c(n,m)); - } - - return 0; -} - -int c(int n,int m) -{ - int res; - - if(n==1||m==0||n==m) - { - res=1; - } - else - { - res=c(n-1,m-1)+c(n-1,m); - } - return res; -} diff --git a/Test/C/程序设计基础I/实验8-指针应用/A - 小泉的难题 .c b/Test/C/程序设计基础I/实验8-指针应用/A - 小泉的难题 .c deleted file mode 100755 index 446a0f8..0000000 --- a/Test/C/程序设计基础I/实验8-指针应用/A - 小泉的难题 .c +++ /dev/null @@ -1,75 +0,0 @@ -/* - Description - 机械实验班有个同学叫小泉,有一天数学老师给小泉布置了一道个人作业,给小泉M(M<=100)组数据,每组数据有N个正整数(N<=100)让他把每组的N个数按升序排成一行,但由于数的数目比较多,人工做很费时,于是小泉就想到了喜欢编程序的你,请你帮他解决这个问题,可不要让他失望噢。 - Input - 输入包括M+1行,第一行是两个正整数M、N;M表示总共多少组数据,下面M行每行包含N个正整数。(输入数据之间会用空格隔开) - Output - 输出包括M行,每行分别对应输入中M组数据的升序序列,数与数之间用一个空格隔开。 - Sample - Input - 2 3 - 1 3 2 - 4 2 6 - Output - 1 2 3 - 2 4 6 - */ -#include -void f(int *p,int n); -int main() -{ - int n,m,i=0,j=0; - int a[100],b[100][100]; - int *p; - - scanf("%d %d",&m,&n); - while(j*(p+j)) - { - t=*(p+i); - *(p+i)=*(p+j); - *(p+j)=t; - } - } - } -} diff --git a/Test/C/程序设计基础I/实验8-指针应用/B - n个数的排序 .c b/Test/C/程序设计基础I/实验8-指针应用/B - n个数的排序 .c deleted file mode 100755 index 6321878..0000000 --- a/Test/C/程序设计基础I/实验8-指针应用/B - n个数的排序 .c +++ /dev/null @@ -1,68 +0,0 @@ -/* - Description - - - LeiQ当上了体育委员,现在老师让他去给班级里的人排队,LeiQ刚学了排序,所以他想以这种方式给班级里的人排队(从矮到高),他想知道排序完成后的结果。 - - Input - 多组输入,每组的第一行是一个正数n(1<=n<=100),第二行是n个数,表示每一个人的高度。 - - - - Output - 输出排序完成后的结果。 - - Sample - Input - 3 - 176 175 174 - Output - 174 175 176 - */ -#include -void f(int *p,int n); -int main() -{ - int n,m,i=0,j=0; - int a[100]; - int *p; - - - while(~scanf("%d",&n)) - { - for(i=0;i*(p+j)) - { - t=*(p+i); - *(p+i)=*(p+j); - *(p+j)=t; - } - } - } -} diff --git a/Test/C/程序设计基础I/实验8-指针应用/C - C语言实验——矩阵下三角元素之和.c b/Test/C/程序设计基础I/实验8-指针应用/C - C语言实验——矩阵下三角元素之和.c deleted file mode 100755 index b90a543..0000000 --- a/Test/C/程序设计基础I/实验8-指针应用/C - C语言实验——矩阵下三角元素之和.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - Description - 输入一个正整数n(1<=n<=10),再输入n*n的矩阵,要求求该矩阵的下三角元素之和。 - - Input - 输入包括n+1行。 - 第一行为整数n; - 接下来的n行为矩阵数据。 - - Output - 矩阵的下三角元素之和。 - - Sample - Input - 5 - 1 2 3 4 5 - 2 3 4 5 6 - 3 4 5 6 7 - 4 5 6 7 8 - 5 6 7 8 9 - Output - 75 - */ -#include -int f(int (*p)[10],int n); -int main() -{ - int n,i,j; - int a[10][10]; - - - scanf("%d",&n); - - for(i=0;i -int main() -{ - char a[5]; - - int i; - - for(i=0;i<5;i++) - { - scanf("%c",&a[i]); - } - - for(i=0;i<5;i++) - { - a[i]=a[i]+4; - } - printf("password is "); - for(i=0;i<5;i++) - { - printf("%c",a[i]); - } - - return 0; -} diff --git a/Test/C/程序设计基础I/实验9-字符串应用/B - C语言实验——保留字母.c b/Test/C/程序设计基础I/实验9-字符串应用/B - C语言实验——保留字母.c deleted file mode 100755 index f4aca52..0000000 --- a/Test/C/程序设计基础I/实验9-字符串应用/B - C语言实验——保留字母.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - Description - 编一个程序,输入一个字符串,将组成字符串的所有非英文字母的字符删除后输出。 - - Input - 一个字符串,长度不超过80个字符。 - - Output - 删掉非英文字母后的字符串。 - - Sample - Input - abc123+xyz.5 - Output - abcxyz - */ -#include -#include -int main() -{ - char a[80],b[80]; - - long int flag,i,j; - char t; - - gets(a); - - flag=strlen(a); - - for(i = 0, j = 0; i < flag; i++) - { - t = a[i]; - if((t >= 'A' && t <= 'Z') || (t >= 'a' && t <= 'z')) - { - b[j] = t; - j++; - } - } - - flag=strlen(b); - - for(i=0;i -#include -int main() -{ - char ch[80],b[80]; - int i,flag; - - gets(ch); - - flag= strlen(ch); - - for(i=0;i='a'&&ch[i]<='z') - printf("%c",ch[i]-32); - else if(ch[i]>='A'&&ch[i]<='Z') - printf("%c",ch[i]+32); - else - printf("%c",ch[i]); - } - return 0; -} diff --git a/Test/C/程序设计基础I/实验9-字符串应用/D - 字符串分割.c b/Test/C/程序设计基础I/实验9-字符串应用/D - 字符串分割.c deleted file mode 100755 index f7f2f33..0000000 --- a/Test/C/程序设计基础I/实验9-字符串应用/D - 字符串分割.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - Description - bLue 获得了一个字符串,现在他要把这个字符串按照某个分隔符来分割成若干个字符串,你能帮他实现吗? - - Input - 输入数据有多组(数据组数不超过 100),到 EOF 结束。 - - 每组数据输入一行,格式为 "s c",其中 s 为一个不含空格且长度不超过 1000 的字符串,表示待分割的字符串;c 为一个不是空格的字符,表示分隔符。 - - - - 输入数据保证在待分割的字符串中,分隔符至少出现一次且不会出现在字符串开头或末尾,并且不会出现连续多个分隔符的情况。 - - Output - 对于每组数据,输出分割后的字符串,每个字符串占一行。 - - Sample - Input - 123,DE , - 0123.a,/45/6.8 / - Output - 123 - DE - 0123.a, - 45 - 6.8 - */ -#include -#include -int main() -{ - int i; - char s[1000],c; - - while(scanf("%s %c",s,&c)!=EOF) - { - for(i=0;i -#include -int main() -{ - int i,j,len; - char str[100],c,ch[100]; - - memset(ch,0,sizeof(ch)); - - scanf("%s %c",str,&c); - - len=strlen(str); - - for(i=0,j=0;i -#include -int main() -{ - char str[100]; - char j; - int i, t; - long int len; - - while (gets(str)) - { - len = strlen(str); - - for(i=0;i='A'&&str[i]<='Z') - { - str[i]=str[i]+32; - } - } - t=0; - for(j='a';j<='z';j++) - { - for(i=0;i -#include -int main() -{ - long int len; - int i,max,j,j_1,flag; - char str[100],sum_1[26],sum_2[26],l_1[26],l_2[26],c; - for(i=0,c='a';i<26;i++,c++) - { - l_1[i]=c; - } - for(i=0,c='A';i<26;i++,c++) - { - l_2[i]=c; - } - while(gets(str)!=NULL) - { - max=0; - memset(sum_1,0,sizeof(sum_1)); - memset(sum_2,0,sizeof(sum_2)); - - len=strlen(str); - - for(i=0;i=0;j--) - { - if (max<=sum_2[j]) - { - max=sum_2[j]; - j_1=j; - flag=0; - } - } - if (flag==0) - printf("%c %d\n",l_2[j_1], max); - else if (flag==1) - printf("%c %d\n",l_1[j_1], max); - - } - - return 0; -} diff --git a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/A - 检查宿舍卫生.cp b/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/A - 检查宿舍卫生.cp deleted file mode 100644 index 54803ec..0000000 --- a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/A - 检查宿舍卫生.cp +++ /dev/null @@ -1,83 +0,0 @@ -/* - Description - 不知道是从哪个学校开始兴起的还是哪个领导的决定,学校里每周都要检查宿舍卫生!大家发现没有,检查宿舍卫生是件很奇葩的事情,它剥削了每件物品的意义:垃圾桶里不能有垃圾,挂钩上不能挂东西,桌子上不能放东西,床上不能躺人!!假设检查卫生分为五项成绩:垃圾桶得分、挂钩得分、桌子得分、床铺得分和窗台得分。每项满分20分,总分满分为100分。按照计算机学院奇葩的规定,宿舍成绩在85分以下就要算作不合格。某天,宿管阿姨给了你一个检查完宿舍的打分表,让你帮忙统计下有多少个宿舍没有达到85分(等于85分是可以的),并且统计成绩最高分。 - - Input - 第一行为一个整数 n (0 < n <= 100),代表你要统计的宿舍的总数,接下来 n 行每行为 5 个整数,代表宿舍五项成绩的得分。 - - Output - 输出只有一行,由一个空格分隔的两个整数:总分不合格的宿舍数和宿舍总分最高分,如果最高分仍小于85分,则输出为不合格的宿舍数和“No”(不包含引号)。 - - Sample - Input - 5 - 1 2 3 4 5 - 10 20 10 20 20 - 20 20 20 20 20 - 15 15 15 20 20 - 10 10 10 10 10 - Output - 3 100 - */ -#include - -using namespace std; - -struct Node -{ - int data; - Node *Next; -}; - -int main() -{ - int n; - int tem; - int sum; - Node *head=new Node; - Node *p=head; - head->Next=nullptr; - - cin>>n; - - for(int i=0;i>tem; - sum+=tem; - } - t->data=sum; - - t->Next=nullptr; - p->Next=t; - - p=t; - } - - p=head->Next; - - int max=-1; - sum=0; - while(p!=nullptr) - { - if(p->data<85) - { - sum++; - } - if(p->data>=max) - { - max=p->data; - } - p=p->Next; - } - - cout< - -using namespace std; - -struct Node -{ - int num; - double data; -}; - -int main() -{ - int n,w1,w2,w3; - int i,t; - double max=-1; - - struct Node a[1000]; - - cin>>n; - - for(i=0;i>w1>>w2>>w3; - a[i].data=w1*0.7+w2*0.2+w3*0.1; - a[i].num=i; - } - t=-1; - while(n--) - { - if(a[n].data>max) - { - max=a[n].data; - t=a[n].num; - } - } - - printf("%d",t); - return 0; -} diff --git a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/C - 选票统计.c b/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/C - 选票统计.c deleted file mode 100755 index 8d71c02..0000000 --- a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/C - 选票统计.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -struct n -{ - int name; - int count; -}; -int main() -{ - int n,m; - struct n a[1000]; - int i,t,j; - - scanf("%d %d",&m,&n); - - for(i=1;i<=m;i++) - { - a[i].name = i; - a[i].count = 0; - } - - for(i=0;it) - { - t=a[i].count; - j=a[i].name; - } - } - - printf("%d\n%d\n",j,t); - return 0; -} diff --git a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/D - 小 I 选宾馆.c b/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/D - 小 I 选宾馆.c deleted file mode 100755 index 861810b..0000000 --- a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/D - 小 I 选宾馆.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - Description - - 小 I 去天津玩啦,一路上,他跟他的同学发生了许多有趣的事。 - - 到了晚上了,小 I 跟他的同学们要选一个宾馆住下了。但是形形色色的宾馆让小 I 不知所措。 - - 对于一个宾馆来说,有许多特征,比如「价格」、「舒适度」。小I会对每个特征都有一个满意度。 - - 小I会选择出满意度更高一些的宾馆。 - - 其中,「价格」对于小 I 来说是最重要的,其次是「舒适度」。 - - 如果有两个宾馆,如果对「价格」的满意度相同,那么根据「舒适度」进行选择;如果有多个宾馆条件相同,输出编号最小的宾馆。 - - 小 I 现在处于水深火热之中,因为他们面对一堆宾馆不知所措,他想到了会编程的你,如果你不帮他选出来,他可能就会露宿街头了QAQ~ - - 你能帮他按照他的意愿找到小I最满意的宾馆吗? - Input - - 给出 n (n <= 5000) 代表 n 个宾馆(编号从 1 - n),随后有 n 行数据。 - - 每行数据有两个整数,分别代表小I对「价格」、「舒适度」的满意程度,数值越大满意程度越高,满意度的范围从0 - 5000。 - Output - - 输出按照描述的条件中小I最满意的宾馆编号,如果有多个宾馆条件相同,输出编号最小的宾馆。 - Sample - - Input - - 4 - 0 1 - 1 0 - 1 1 - 1 0 - Output - - 3 - #include - #include - using namespace std; - - struct Node - { - int price; - int com; - int num; - }; - - int main() - { - Node a[5010]; - memset(a,0,sizeof (a)); - - int N; - cin>>N; - - for(int i=0;i>a[i].price>>a[i].com; - a[i].num=i+1; - } - - for(int i=0;i -struct node -{ - int name; - int prise; - int comfort; -}; -int main() -{ - int n; - struct node a[5500]; - int i,t,j,fl; - - scanf("%d",&n); - - for(i=1;i<=n;i++) - { - a[i].name = i; - a[i].prise = 0; - a[i].comfort = 0; - } - - for(i=1;i<=n;i++) - { - scanf("%d %d",&a[i].prise,&a[i].comfort); - } - - t=0; - j=-1; - fl=1; - for(i=1;i<=n;i++) - { - if(a[i].prise>t) - { - t=a[i].prise; - fl=a[i].name; - j=a[i].comfort; - } - if(a[i].prise==t) - { - if(a[i].comfort>j) { - t = a[i].prise; - fl = a[i].name; - j = a[i].comfort; - } - if(a[i].comfort==j) - { - if(a[i].name<=fl) - { - t = a[i].prise; - fl = a[i].name; - j = a[i].comfort; - } - } - } - } - - printf("%d\n",fl); - - return 0; -} - diff --git a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/E - 小鑫の日常系列故事(十)——排名次 .c b/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/E - 小鑫の日常系列故事(十)——排名次 .c deleted file mode 100755 index 9aa9cbe..0000000 --- a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/E - 小鑫の日常系列故事(十)——排名次 .c +++ /dev/null @@ -1,38 +0,0 @@ -#include -struct student -{ - char name[20]; - int score; -}; -int main() -{ - struct student st[100]; - struct student t; - int n,i,j; - - scanf("%d",&n); - - for(i=0;i -struct student -{ - long int name; - int score; -}; -int main() -{ - struct student st[10005]; - struct student t; - int n,i,j; - - scanf("%d",&n); - - for(i=0;i -struct BY -{ - char name[20]; - int h; - int w; - int flag; -}; -int main() -{ - struct BY inf[1005]; - int a,b,c,d; - int n,i,j; - struct BY temp; - int f=0; - - scanf("%d",&n); - - for(i=0;id)||(inf[i].hb)) - { - inf[i].flag=0; - } - } - - for(i=0;iinf[j+1].h) - { - temp=inf[j]; - inf[j]=inf[j+1]; - inf[j+1]=temp; - } - - if(inf[j].h==inf[j+1].h) - { - if(inf[j].w>inf[j+1].w) - { - temp=inf[j]; - inf[j]=inf[j+1]; - inf[j+1]=temp; - } - } - } - - } - - for(i=0;i -struct compare -{ - int qu; - int pr; -}; -int main() -{ - int n; - int i,j; - struct compare cmp[100]; - struct compare temp; - - scanf("%d",&n); - - for(i=0;icmp[i+1].qu) - { - temp=cmp[i]; - cmp[i]=cmp[i+1]; - cmp[i+1]=temp; - } - - if(cmp[i].qu==cmp[i+1].qu) - { - if(cmp[i].pr -#include -using namespace std; - -union node -{ - int a; - double b; - char s[30]; -}; - -char book[112345][30]; -int main() -{ - int n, m,k; - union node q[112345]; - scanf("%d %d", &n, &m); - int i; - for(i = 0;i < n;i++) - { - scanf("%s", book[i]); - if(strcmp(book[i],"INT") == 0) - { - scanf("%d", &q[i].a); - } - else if(strcmp(book[i], "DOUBLE") == 0) - { - scanf("%lf", &q[i].b); - } - else if(strcmp(book[i],"STRING") == 0) - { - scanf("%s", q[i].s); - } - } - - for(i = 0;i < m;i++) - { - scanf("%d", &k); - if(strcmp(book[k],"INT") == 0) - { - printf("%d\n", q[k].a); - } - else if(strcmp(book[k], "DOUBLE") == 0) - { - printf("%.2f\n", q[k].b); - } - else if(strcmp(book[k],"STRING") == 0) - { - printf("%s\n", q[k].s); - } - } - - - return 0; -} diff --git a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/J - 简单枚举类型——植物与颜色.c b/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/J - 简单枚举类型——植物与颜色.c deleted file mode 100755 index d3a9953..0000000 --- a/Test/C/程序设计基础II/ 实验1- 结构体、共用体和枚举/J - 简单枚举类型——植物与颜色.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -enum color -{ - red,orange,yellow,green,blue,violet,no -}; -int main() -{ - enum color a; - char s[35]; - int n,i; - scanf("%d",&n); - for(i=0;i -#include -struct node -{ - int num; - struct node *next; -}; -int main() -{ - struct node *head; - struct node *tail; - struct node *p; - head = (struct node *)malloc(sizeof (struct node)); - int n,i; - tail = head; - scanf("%d",&n); - - for(i=0;inum); - p->next=NULL; - tail->next=p; - tail = p; - } - p=head->next; - - while(p!=NULL) - { - printf("%d ",p->num); - p=p->next; - } - - return 0; -} diff --git a/Test/C/程序设计基础II/实验2——链表/B - 数据结构实验之链表二:逆序建立链表.cp b/Test/C/程序设计基础II/实验2——链表/B - 数据结构实验之链表二:逆序建立链表.cp deleted file mode 100644 index 6ff5f15..0000000 --- a/Test/C/程序设计基础II/实验2——链表/B - 数据结构实验之链表二:逆序建立链表.cp +++ /dev/null @@ -1,57 +0,0 @@ -/* - Description - 输入整数个数N,再输入N个整数,按照这些整数输入的相反顺序建立单链表,并依次遍历输出单链表的数据。 - Input - 第一行输入整数N;; - 第二行依次输入N个整数,逆序建立单链表。 - Output - 依次输出单链表所存放的数据。 - Sample - Input - 10 - 11 3 5 27 9 12 43 16 84 22 - Output - 22 84 16 43 12 9 27 5 3 11 - Hint - 不能使用数组! - - */ -#include - -using namespace std; - -struct Node -{ - int data; - - Node *Next; -}; -int main() -{ - Node *head = new Node; - Node *p=nullptr; - head->Next=nullptr; - - int n; - - cin>>n; - - while(n--) - { - Node *t = new Node; - - scanf("%d",&t->data); - head->Next=t; - t->Next=p; - p=t; - } - - p=head->Next; - while(p != nullptr) - { - cout<data<<" "; - p=p->Next; - } - - return 0; -} diff --git a/Test/C/程序设计基础II/实验2——链表/C - 师--链表的结点插入.cp b/Test/C/程序设计基础II/实验2——链表/C - 师--链表的结点插入.cp deleted file mode 100644 index caf4c3a..0000000 --- a/Test/C/程序设计基础II/实验2——链表/C - 师--链表的结点插入.cp +++ /dev/null @@ -1,85 +0,0 @@ -/* - Description - 给出一个只有头指针的链表和 n 次操作,每次操作为在链表的第 m 个元素后面插入一个新元素x。若m 大于链表的元素总数则将x放在链表的最后。 - - Input - 多组输入。每组数据首先输入一个整数n(n∈[1,100]),代表有n次操作。 - - 接下来的n行,每行有两个整数Mi(Mi∈[0,10000]),Xi。 - - Output - 对于每组数据。从前到后输出链表的所有元素,两个元素之间用空格隔开。 - - Sample - Input - 4 - 1 1 - 1 2 - 0 3 - 100 4 - Output - 3 1 2 4 - Hint - 样例中第一次操作1 1,由于此时链表中没有元素,1>0,所以此时将第一个数据插入到链表的最后,也就是头指针的后面。 - */ -#include - -using namespace std; - -struct Node -{ - int data; - Node *Next; -}; - -int main() -{ - int n; - int mi; - int flag; - - while(cin>>n) - { - Node *head=new Node; - Node *p=head; - p->Next=nullptr; - - flag=0; - - while(n--) - { - Node *t = new Node; - cin>>mi>>t->data; - - if(mi>flag) - mi=flag; - - p=head; - while(mi--) - p=p->Next; - - t->Next=p->Next; - p->Next=t; - flag++; - } - - p=head->Next; - while(p!= nullptr) - { - if(p==head->Next) - { - cout<data; - } - else - cout<<" "<data; - p=p->Next; - } - - if(p == NULL) - { - cout< -#include -#include -struct Node -{ - int Data; - struct Node *Next; -}; - -int main() -{ - int a[20]={0}; - memset(a,0,sizeof a); - int n; - struct Node *head=(struct Node *)malloc(sizeof (struct Node)); - struct Node *p=head; - p->Next=NULL; - - scanf("%d",&n); - - for(int i=0;iData); - t->Next=head->Next; - head->Next=t; - } - - printf("%d\n",n); - p=head->Next; - while(p) - { - if(!p->Next) - printf("%d\n",p->Data); - else - printf("%d ",p->Data); - p=p->Next; - } - - - int count=0,temp; - p=head; - while(p->Next) - { - int flag=1; - for(int i=0;iNext->Data==a[i]) - { - struct Node *t=p->Next; - if(!p->Next->Next) - { - p->Next=NULL; - flag=0; - break; - } - else - p->Next=p->Next->Next; - free(t); - flag=0; - break; - } - } - if (flag) - { - a[count++]=p->Next->Data; - p=p->Next; - } - - } - - printf("%d\n",count); - p=head->Next; - while(p) - { - if(!p->Next) - printf("%d\n",p->Data); - else - printf("%d ",p->Data); - p=p->Next; - } - - - - return 0; -} diff --git a/Test/C/程序设计基础II/实验2——链表/D - 数据结构实验之链表七:单链表中重复元素的删除.cp b/Test/C/程序设计基础II/实验2——链表/D - 数据结构实验之链表七:单链表中重复元素的删除.cp deleted file mode 100644 index a5fb64e..0000000 --- a/Test/C/程序设计基础II/实验2——链表/D - 数据结构实验之链表七:单链表中重复元素的删除.cp +++ /dev/null @@ -1,109 +0,0 @@ -/* - Description -按照数据输入的相反顺序(逆位序)建立一个单链表,并将单链表中重复的元素删除(值相同的元素只保留最后输入的一个)。 - -Input -第一行输入元素个数 n (1 <= n <= 15); -第二行输入 n 个整数,保证在 int 范围内。 - -Output -第一行输出初始链表元素个数; -第二行输出按照逆位序所建立的初始链表; -第三行输出删除重复元素后的单链表元素个数; -第四行输出删除重复元素后的单链表。 - -Sample -Input -10 -21 30 14 55 32 63 11 30 55 30 -Output -10 -30 55 30 11 63 32 55 14 30 21 -7 -30 55 11 63 32 14 21 - */ -#include - -using namespace std; - -struct Node -{ - int data; - - Node *Next; -}; -int main() -{ - Node *head = new Node; - Node *p=nullptr; - head->Next=nullptr; - - Node *res = new Node; - Node *pres = res; - pres->Next= nullptr; - - int n,ans=0; - - cin>>n; - - for(int i=0;i>t->data; - head->Next=t; - t->Next=p; - p=t; - } - - cout<Next; - while(p != nullptr) - { - cout<data<<" "; - p=p->Next; - } - - cout<Next; - while(p) - { - pres=res; - while(pres) - { - if(pres->data==p->data) - { - break; - } - else - { - if(pres->Next!=nullptr) - { - pres=pres->Next; - continue; - } - else - { - Node *t=new Node; - t->data=p->data; - t->Next=nullptr; - pres->Next=t; - ans++; - break; - } - } - } - p=p->Next; - } - - cout<Next; - while(pres) - { - cout<data<<" "; - pres=pres->Next; - } - - return 0; -} diff --git a/Test/C/程序设计基础II/实验2——链表/E - 数据结构实验之链表三:链表的逆置 .cp b/Test/C/程序设计基础II/实验2——链表/E - 数据结构实验之链表三:链表的逆置 .cp deleted file mode 100644 index eca3ee6..0000000 --- a/Test/C/程序设计基础II/实验2——链表/E - 数据结构实验之链表三:链表的逆置 .cp +++ /dev/null @@ -1,51 +0,0 @@ -/* -Description -输入多个整数,以-1作为结束标志,顺序建立一个带头结点的单链表,之后对该单链表的数据进行逆置,并输出逆置后的单链表数据。 -Input -输入多个整数,以-1作为结束标志。 -Output -输出逆置后的单链表数据。 -Sample -Input -12 56 4 6 55 15 33 62 -1 -Output -62 33 15 55 6 4 56 12 -Hint -不得使用数组。 - */ -#include - -using namespace std; - -struct Node -{ - int data; - Node *Next; -}; - -int main() -{ - Node *head=new Node; - head->Next=nullptr; - - int temp; - while(cin>>temp&&temp!=-1) - { - Node *t=new Node; - t->data=temp; - t->Next=head->Next; - head->Next=t; - } - - Node *p=head->Next; - - while(p) - { - cout<data<<" "; - p=p->Next; - } - cout< - -using namespace std; - -struct Node -{ - int data; - Node *Next; -}; - -int main() -{ - int n,m; - - Node *head = new Node; - Node *p=head; - Node *head2 = new Node; - p->Next=nullptr; - - cin>>m>>n; - - while(m--) - { - Node *t=new Node; - scanf("%d",&t->data); - t->Next=p->Next; - p->Next=t; - p=t; - } - - p=head2; - p->Next=nullptr; - - while(n--) - { - Node *t=new Node; - scanf("%d",&t->data); - t->Next=p->Next; - p->Next=t; - p=t; - } - - p=head->Next; - Node *p2=head2->Next; - Node *t=head; - while(p&&p2) - { - if(p->data>p2->data) - { - t->Next=p2; - t=p2; - p2=p2->Next; - } - else - { - t->Next=p; - t=p; - p=p->Next; - } - } - if(p) - { - t->Next=p; - } - else - { - t->Next=p2; - } - - p=head->Next; - while(p) - { - cout<data<<" "; - p=p->Next; - } - cout< - -using namespace std; - -struct Node -{ - int data; - Node *Next; -}; - -int main() -{ - int n; - int count1=0; - int count2=0; - Node *head=new Node; - Node *p=head; - p->Next=nullptr; - - Node *res1=new Node; - Node *res2=new Node; - Node *p1=res1; - Node *p2=res2; - p1->Next=nullptr; - p2->Next=nullptr; - - cin>>n; - - while(n--) - { - Node *t=new Node; - cin>>t->data; - t->Next=p->Next; - p->Next=t; - p=t; - } - - p=head->Next; - while(p) - { - if(p->data%2==0) - { - Node *t=new Node; - count2++; - t->data=p->data; - p2->data=t->data; - t->Next=p2->Next; - p2->Next=t; - p2=t; - } - else - { - Node *t = new Node; - count1++; - t->data=p->data; - p1->data=t->data; - t->Next=p1->Next; - p1->Next=t; - p1=t; - } - p=p->Next; - } - - - cout<Next) - { - cout<data<<" "; - p2=p2->Next; - } - cout<Next) - { - cout<data<<" "; - p1=p1->Next; - } - cout< - -using namespace std; - -struct Node -{ - int data; - Node *Back; - Node *Next; -}; - -int main() -{ - int n,m; - int t; - - Node *head = new Node; - Node *p=head; - p->Next=nullptr; - - cin>>n>>m; - - while(n--) - { - Node *t = new Node; - cin>>t->data; - - t->Back=p; - t->Next=p->Next; - p->Next=t; - p=t; - } - - - while(m--) - { - cin>>t; - int flag=0; - - p=head->Next; - while(p->data!=t&&p != nullptr) - { - p=p->Next; - } - - if(p->data==t) - flag=1; - - if(flag==0) - { - continue; - } - else - { - if(p->Back&&p->Back!=head) - { - cout<Back->data; - if(p->Next) - cout<<" "; - } - - if(p->Next) - { - cout<Next->data; - } - - cout< -#include -struct Node -{ - int data; - struct Node *Next; -}; -int main() -{ - int n,m; - int i,t; - scanf("%d %d",&n,&m); - struct Node *head = (struct Node *)malloc(sizeof(struct Node)); - struct Node *tail =head; - struct Node *p,*die; - tail->Next = NULL; - - for(i=1;idata = i+1; - p->Next = NULL; - tail->Next = p; - tail = p; - } - head->data = 1; - tail->Next = head; - t=n; - - p=head; - while (t>1) - { - - for(i=0;iNext; - } - die = p->Next; - - p->Next=die->Next; - free(die); - t--; - p=p->Next; - } - printf("%d\n",p->data); - - return 0; -} diff --git a/Test/C/程序设计基础II/实验2——链表/J - 不敢死队问题.cp b/Test/C/程序设计基础II/实验2——链表/J - 不敢死队问题.cp deleted file mode 100644 index abab894..0000000 --- a/Test/C/程序设计基础II/实验2——链表/J - 不敢死队问题.cp +++ /dev/null @@ -1,89 +0,0 @@ -/* - Description - 说到“敢死队”,大家不要以为我来介绍电影了,因为数据结构里真有这么道程序设计题目,原题如下: - - - - 有M个敢死队员要炸掉敌人的一个碉堡,谁都不想去,排长决定用轮回数数的办法来决定哪个战士去执行任务。如果前一个战士没完成任务,则要再派一个战士上去。现给每个战士编一个号,大家围坐成一圈,随便从某一个战士开始计数,当数到5时,对应的战士就去执行任务,且此战士不再参加下一轮计数。如果此战士没完成任务,再从下一个战士开始数数,被数到第5时,此战士接着去执行任务。以此类推,直到任务完成为止。 - - - - 这题本来就叫“敢死队”。“谁都不想去”,就这一句我觉得这个问题也只能叫“不敢死队问题”。今天大家就要完成这道不敢死队问题。我们假设排长是1号,按照上面介绍,从1号开始数,数到5的那名战士去执行任务,那么排长是第几个去执行任务的? - - Input - 输入包括多组数据,每组一行,包含一个整数M(0<=M<=10000)(敢死队人数),若M==0,输入结束,不做处理。 - - Output - 输出一个整数n,代表排长是第n个去执行任务。 - - Sample - Input - 9 - 6 - 223 - 0 - Output - 2 - 6 - 132 - */ -#include -#include -struct Node -{ - int data; - struct Node *Next; -}; -int main() -{ - int n,m; - int i,t; - int flag = 1; - while(~scanf("%d",&n)&&n!=0) - { - m=5; - flag = 1; - struct Node *head = (struct Node *)malloc(sizeof(struct Node)); - struct Node *tail =head; - struct Node *p,*die; - tail->Next = NULL; - - for(i=1;idata = i+1; - p->Next = NULL; - tail->Next = p; - tail = p; - } - - head->data = 1; - tail->Next = head; - t=n; - - p=head; - while (t>1) - { - for(i=0;iNext; - } - die = p->Next; - if(die->data == 1) - { - break; - } - p->Next=die->Next; - free(die); - flag++; - t--; - p=p->Next; - } - printf("%d\n",flag); - } - - - - - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/A - 养兔子.c b/Test/C/程序设计基础II/实验3——递推/A - 养兔子.c deleted file mode 100755 index a0b387b..0000000 --- a/Test/C/程序设计基础II/实验3——递推/A - 养兔子.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - Description - - 一对成熟的兔子每天能且只能产下一对小兔子,每次都生一公一母,每只小兔子的成熟期是1天,小兔子出生后隔一天才能再生小兔子。第一天某人领养了一对成熟的兔子,一公一母,请问第N天以后,他将会得到多少对兔子。 - Input - - 输入为一个整数n(1 ≤ n ≤ 90)。 - Output - - 对应输出第n天有几对兔子(假设没有兔子死亡现象,而且是一夫一妻制)。 - Sample - - Input - - 2 - Output - - 2 - Hint - - 数据类型可以用64位整数:long long - */ -#include -int main() -{ - int n; - long long int sum[90]; - int i; - - scanf("%d",&n); - sum[0]=1; - sum[1]=2; - for(i=2;i -int main() -{ - int n; - long long int sum[90]; - int i; - - scanf("%d",&n); - sum[1]=1; - sum[2]=2; - sum[3]=3; - sum[4]=4; - for(i=5;i<=n;i++) - { - sum[i]=sum[i-1]+sum[i-3]; - } - - printf("%lld",sum[n]); - - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/C - 鬼吹灯之龙岭迷窟 .c b/Test/C/程序设计基础II/实验3——递推/C - 鬼吹灯之龙岭迷窟 .c deleted file mode 100755 index a193e8f..0000000 --- a/Test/C/程序设计基础II/实验3——递推/C - 鬼吹灯之龙岭迷窟 .c +++ /dev/null @@ -1,41 +0,0 @@ -/* - Description - - 在古希腊时期,有一天毕达哥拉斯走在街上,在经过铁匠铺前他听到铁匠打铁的声音非常好听,于是驻足倾听。他发现铁匠打铁节奏很有规律,这个声音的比例被毕达哥拉斯用数学的方式表达出来。 - - 这个比例就叫做黄金分割比,它是指将整体一分为二,较大部分与整体部分的比值等于较小部分与较大部分的比值,其比值约为0.6180339887。这个比例被公认为是最能引起美感的比例,因此被称为黄金分割。 - - 现在小玉有一个正整数数列,这个数列的前一项和后一项的比值十分趋近于黄金分割比,即(a[i])/(a[i+1])~ 0.6180339887,(i>=1),可是她只知道数列的第一项是5,现在她想通过已有条件推断出数列的任意项,请你帮助她编写一个程序计算。 - Input - - 输入一个整数n(1<=n<=20)。 - Output - - 输出一个数,代表这个数列的第n项a[n]。 - Sample - - Input - - 1 - Output - - 5 - - */ -#include -int main() -{ - int n,i; - int a[20]; - a[0]=5; - scanf("%d",&n); - - for(i=1;i<=n;i++) - { - a[i]=(a[i-1]/0.6180339887)+0.5; - } - - printf("%d\n",a[n-1]); - - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/D - 骨牌铺方格.c b/Test/C/程序设计基础II/实验3——递推/D - 骨牌铺方格.c deleted file mode 100644 index ec3b405..0000000 --- a/Test/C/程序设计基础II/实验3——递推/D - 骨牌铺方格.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - Description - 在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数. 例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图: - - - Input - 输入包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0< n<=50)。 - - Output - 输出铺放方案的总数。 - - Sample - Input - 3 - Output - 3 - */ -#include -#define ll long long -int main() -{ - ll a[55]={0}; - - int n; - - scanf("%d",&n); - - a[0]=0; - a[1]=1; - a[2]=2; - a[3]=3; - - for(int i=3;i<=n;i++) - { - a[i]=a[i-1]+a[i-2]; - } - printf("%lld",a[n]); - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/E - 爬楼梯.cp b/Test/C/程序设计基础II/实验3——递推/E - 爬楼梯.cp deleted file mode 100644 index 0a68136..0000000 --- a/Test/C/程序设计基础II/实验3——递推/E - 爬楼梯.cp +++ /dev/null @@ -1,39 +0,0 @@ -/* - Description - 小明是个非常无聊的人,他每天都会思考一些奇怪的问题,比如爬楼梯的时候,他就会想,如果每次可以上一级台阶或者两级台阶,那么上 n 级台阶一共有多少种方案? - - Input - 输入只有一行为一个正整数 n(1 ≤ n ≤ 50)。 - - Output - 输出符合条件的方案数。 - 注意:64-bit 整型请使用 long long 来定义,并且使用 %lld 或 cin、cout 来输入输出,请不要使用 __int64 和 %I64d。 - - Sample - Input - 4 - Output - 5 - */ -#include -#define ll long long -int main() -{ - int n; - ll a[55]; - - scanf("%d",&n); - - a[0]=0; - a[1]=1; - a[2]=2; - a[3]=3; - - for(int i=3;i<=n;i++) - { - a[i]=a[i-1]+a[i-2]; - } - - printf("%lld",a[n]); - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/F - 三国佚事——巴蜀之危 .cp b/Test/C/程序设计基础II/实验3——递推/F - 三国佚事——巴蜀之危 .cp deleted file mode 100644 index 02afe9b..0000000 --- a/Test/C/程序设计基础II/实验3——递推/F - 三国佚事——巴蜀之危 .cp +++ /dev/null @@ -1,40 +0,0 @@ -/* - Description - 话说天下大势,分久必合,合久必分。。。却道那魏蜀吴三国鼎力之时,多少英雄豪杰以热血谱写那千古之绝唱。古人诚不我欺,确是应了那句“一将功成万骨枯”。 - 是夜,明月高悬。诸葛丞相轻摇羽扇,一脸愁苦。原来是日前蜀国战事吃紧,丞相彻夜未眠,奋笔急书,于每个烽火台写下安排书信。可想,这战事多变,丞相运筹 帷幄,给诸多烽火台定下不同计策,却也实属不易。 - 谁成想这送信小厮竟投靠曹操,给诸葛丞相暗中使坏。这小厮将每封书信都投错了烽火台,居然没有一封是对的。不多时小厮便被抓住,前后之事却也明朗。这可急坏了诸葛丞相,这书信传错,势必会让蜀军自乱阵脚,不攻自破啊! 诸葛丞相现在想知道被这小厮一乱,这书信传错共有多少种情况。 - - Input - 输入一个正数n,代表丞相共写了n(1 <= n <= 20)封书信。 - - Output - 输出书信传错的情况数。 - - Sample - Input - 3 - Output - 2 - */ -#include -#define ll long long - -int main() -{ - int n; - ll a[21]; - scanf("%d",&n); - a[0]=0; - a[1]=0; - a[2]=1; - - - for(int i=3;i<=n;i++) - { - a[i]=(i-1)*(a[i-1]+a[i-2]); - } - printf("%lld",a[n]); - - - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/G - 王小二切饼.cp b/Test/C/程序设计基础II/实验3——递推/G - 王小二切饼.cp deleted file mode 100644 index a9bb0be..0000000 --- a/Test/C/程序设计基础II/实验3——递推/G - 王小二切饼.cp +++ /dev/null @@ -1,36 +0,0 @@ -/* - 王小二自夸刀工不错,有人放一张大的煎饼在砧板上,问他:“饼不许离开砧板,切n(1<=n<=100)刀最多能分成多少块?” - - 输入格式: - 输入切的刀数n。 - - 输出格式: - 输出为切n刀最多切的饼的块数。 - - 输入样例: - 100 - 输出样例: - 5051 - */ -#include -#define ll long long - -int main() -{ - int n; - ll a[110]; - scanf("%d",&n); - a[0]=1; - a[1]=2; - a[2]=4; - - for(int i=1;i<=n;i++) - { - a[i]=a[i-1]+i; - } - - printf("%lld",a[n]); - - - return 0; -} diff --git a/Test/C/程序设计基础II/实验3——递推/黄金时代.c b/Test/C/程序设计基础II/实验3——递推/黄金时代.c deleted file mode 100644 index fd92f84..0000000 --- a/Test/C/程序设计基础II/实验3——递推/黄金时代.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - 在古希腊时期,有一天毕达哥拉斯走在街上,在经过铁匠铺前他听到铁匠打铁的声音非常好听,于是驻足倾听。他发现铁匠打铁节奏很有规律,这个声音的比例被毕达哥拉斯用数学的方式表达出来。 - - 这个比例就叫做黄金分割比,它是指将整体一分为二,较大部分与整体部分的比值等于较小部分与较大部分的比值,其比值约为0.6180339887。这个比例被公认为是最能引起美感的比例,因此被称为黄金分割。 - - 现在小玉有一个正整数数列,这个数列的前一项和后一项的比值十分趋近于黄金分割比,即(a[i])/(a[i+1])~ 0.6180339887,(i>=1),可是她只知道数列的第一项是5,现在她想通过已有条件推断出数列的任意项,请你帮助她编写一个程序计算。(请留意题目提示) - - 输入格式: - 每次输入一个整数n(1<=n<=20) - - 输出格式: - 输出一个数,代表这个数列的第n项a[n]。 - - 输入样例: - 1 - 输出样例: - 5 - */ -#include -int main() -{ - int n,i; - int a[20]; - a[0]=5; - scanf("%d",&n); - - for(i=1;i<=n;i++) - { - a[i]=(a[i-1]/0.6180339887)+0.5; - } - - printf("%d\n",a[n-1]); - - return 0; -} diff --git a/Test/C/程序设计基础II/实验4——递归/A - 计算组合数.c b/Test/C/程序设计基础II/实验4——递归/A - 计算组合数.c deleted file mode 100644 index dc9469b..0000000 --- a/Test/C/程序设计基础II/实验4——递归/A - 计算组合数.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - #include - long long int f(int n,int m); - - int main() - { - int n,m,N; - - scanf("%d",&N); - - for(int i=0;i -long long int f(int n,int m); - -int main() -{ - int n,m,N; - - scanf("%d",&N); - - for(int i=0;i -long long int f(int n,int m); - -int main() -{ - int n,m,N; - int i,j; - scanf("%d",&N); - - for(i=0;i0且n=0,返回F(m-1,1)。 - - 若m>0且n>0,返回F(m-1,F(m,n-1))。 - - - - 给出 m 和 n,计算 F(m, n) 的值。 - Input - - 第一行输入一个整数 t, 代表有 t 组数据。(1 <= t <= 15) - - 每组数据输入一行,包含两个非负整数 m,n。(0 <= m <= 3, 0 <= n <= 10) - Output - - 每组数据输出一行,为 F(m, n) 的答案。 - Sample - - Input - - 3 - 3 2 - 3 10 - 2 1 - Output - - 29 - 8189 - 5 - */ -#include -long long int f(int m,int n); - -int main() -{ - int n,m,N; - int i,j; - scanf("%d",&N); - - for(i=0;i0&&n==0) - return f(m-1, 1); - else if(m>0&&n>0) - return f(m-1,f(m,n-1)); - -} diff --git a/Test/C/程序设计基础II/实验4——递归/H - M--二分查找.cp b/Test/C/程序设计基础II/实验4——递归/H - M--二分查找.cp deleted file mode 100644 index 72cf725..0000000 --- a/Test/C/程序设计基础II/实验4——递归/H - M--二分查找.cp +++ /dev/null @@ -1,58 +0,0 @@ -/* - Description - 给出含有n个数的升序序列,保证序列中的数两两不相等,这n个数编号从1 到n。 - 然后给出q次询问,每次询问给出一个数x,若x存在于此序列中,则输出其编号,否则输出-1。 - Input - 单组输入。首先输入一个整数n(1 <= n && n <= 3000000),接下的一行包含n个数。 - 再接下来的一行包含一个正整数q(1 <= q && q <= 10000),表示有q次询问。 - 再接下来的q行,每行包含一个正整数x。 - Output - 对于每次询问,输出一个整数代表答案。 - Sample - Input - 5 - 1 3 5 7 9 - 3 - 1 - 5 - 8 - Output - 1 - 3 - -1 - */ -#include - -using namespace std; -const int N=300000; -int a[N]; - -int find(int l,int r,int x) -{ - if(l>r) - return -1; - int mid=(l+r)/2; - - if(a[mid]==x) - return mid+1; - else if(a[mid]>x) - return find(l,mid-1,x); - else if(a[mid]>n; - for(int i=0;i>a[i]; - - cin>>q; - while(q--) - { - cin>>x; - cout< - -using namespace std; - -int main() -{ - int n; - string a; - a.clear(); - cin>>a>>n; - - int len=a.length(); - - while(n) - { - int i=0; - while(i1&&a[0]=='0') - a.erase(0,1); - - cout< - -using namespace std; - -struct Node -{ - int st; - int end; - int num; -}; - -int main() -{ - int n; - Node a[110]={0}; - - cin>>n; - - for(int i=0;i>a[i].st>>a[i].end; - - a[i].num=i+1; - } - - for(int i=0;ia[j+1].end) - { - swap(a[j],a[j+1]); - } - } - } - - printf("%d",a[0].num); - - int t=a[0].end; - for(int i=1;i=t) - { - printf(",%d",a[i].num); - t=a[i].end; - } - } - - - return 0; -} diff --git a/Test/C/程序设计基础II/实验5--贪心/C - 活动选择问题.cp b/Test/C/程序设计基础II/实验5--贪心/C - 活动选择问题.cp deleted file mode 100644 index 3b74aa5..0000000 --- a/Test/C/程序设计基础II/实验5--贪心/C - 活动选择问题.cp +++ /dev/null @@ -1,78 +0,0 @@ -/* - Description - sdut 大学生艺术中心每天都有n个活动申请举办,但是为了举办更多的活动,必须要放弃一些活动,求出每天最多能举办多少活动。 - - Input - 输入第一行为申请的活动数n(n<100),从第2行到n+1行,每行两个数,是每个活动的开始时间b,结束时间e; - - Output - 输出每天最多能举办的活动数。 - - Sample - Input - 12 - 15 20 - 15 19 - 8 18 - 10 15 - 4 14 - 6 12 - 5 10 - 2 9 - 3 8 - 0 7 - 3 4 - 1 3 - Output - 5 - */ -#include - -using namespace std; - -struct Node -{ - int st; - int end; - int num; -}; - -int main() -{ - int n; - Node a[110]={0}; - - cin>>n; - - for(int i=0;i>a[i].st>>a[i].end; - - a[i].num=i+1; - } - - for(int i=0;ia[j+1].end) - { - swap(a[j],a[j+1]); - } - } - } - int count=1; - int t=a[0].end; - - for(int i=1;i=t) - { - count++; - t=a[i].end; - } - } - cout< 20 或 b > 20 或 c > 20 返回值为 f(20, 20, 20); - 如果 a < b 并且 b < c 返回 f(a, b, c−1) + f(a, b−1, c−1) − f(a, b−1, c); - 其它情况返回 f(a−1, b, c) + f(a−1, b−1, c) + f(a−1, b, c−1) − f(a-1, b-1, c-1)。 - 看起来简单的一个函数?你能做对吗? - Input - - 输入包含多组测试数据,对于每组测试数据: - 输入只有一行为 3 个整数a, b, c(a, b, c < 30)。 - Output - - 对于每组测试数据,输出函数的计算结果。 - Sample - - Input - - 1 1 1 - 2 2 2 - Output - - 2 - 4 - - */ -#include -#include -int dp[30][30][30]; -int f(int a,int b,int c) -{ - int res; - if(a<=0||b<=0||c<=0) - return 1; - if(a>20||b>20||c>20) - return f(20,20,20); - if(dp[a][b][c]!=0) - return dp[a][b][c]; - if(a0) - { - sum=0; - M=in.nextInt(); - while(M>0) - { - t=in.nextInt(); - sum+=t; - M--; - } - System.out.printf("%d\n\n",sum); - N--; - } - - - } -} \ No newline at end of file diff --git a/Test/Java/A/Hello World!.java b/Test/Java/A/Hello World!.java deleted file mode 100644 index 3d63fdb..0000000 --- a/Test/Java/A/Hello World!.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Main -{ - public static void main(String [] args) - { - System.out.print("Hello World!\n"); - } -} \ No newline at end of file diff --git a/Test/Java/A/格式化输出(常量练习).java b/Test/Java/A/格式化输出(常量练习).java deleted file mode 100644 index d781462..0000000 --- a/Test/Java/A/格式化输出(常量练习).java +++ /dev/null @@ -1,34 +0,0 @@ -/* -Description -用c语言的基本输出格式打印下列内容: -100 -A -3.140000 - -Input -本题目没有输入数据 - -Output -输出三行数据: -100 -A -3.140000 - -Sample -Output -100 -A -3.140000 -*/ -public class Main -{ - public static void main(String [] args) - { - int a=100; - char c='A'; - double f=3.140000; - System.out.printf("%d\n",a); - System.out.printf("%c\n",c); - System.out.printf("%f\n",f); - } -} \ No newline at end of file diff --git a/Test/Java/A/洗衣服.java b/Test/Java/A/洗衣服.java deleted file mode 100644 index 125c1ca..0000000 --- a/Test/Java/A/洗衣服.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -Description -X是一个勤劳的小孩,总是会帮助大人做家务。现在他想知道对于一根长为L的绳子能晾开多少件宽为W的衣服,显然这些衣服不能相互叠压。 -Input - 多组输入。 -每组输入两个整数L,W。 -Output - 输出答案。 -Sample -Input -10 5 -10 4 -Output -2 -2 - */ -import java.util.Scanner; -public class Main -{ - public static void main(String [] args) - { - Scanner in = new Scanner(System.in); - int L,W; - while(in.hasNextInt()) - { - L=in.nextInt(); - W=in.nextInt(); - System.out.printf("%d\n",L/W); - } - } -} \ No newline at end of file diff --git a/Test/Java/A/火车.java b/Test/Java/A/火车.java deleted file mode 100644 index ca1412d..0000000 --- a/Test/Java/A/火车.java +++ /dev/null @@ -1,31 +0,0 @@ -import java.util.Scanner; - -public class Main -{ - public static void main(String [] args) - { - int T,n,a,b; - int max,temp; - Scanner in =new Scanner(System.in); - T=in.nextInt(); - - while(T!=0) - { - max=0; - temp=0; - n=in.nextInt(); - while(n!=0) - { - a=in.nextInt(); - b=in.nextInt(); - temp=temp-a+b; - if(max -#include -#include -int TenNum(char a[],int B); //将输入的数字转换成10进制数 -void Numchange(int m, int B); //将转换好了的10进制数转换为所需进制数 -int TenNum(char a[], int B) -{ - long int len; - int i, num = 0; - int sum = 0; - len = strlen(a); //求得字符串长度 - for (i = 0; i < len; i++) - { - if (a[i] >= '0' && a[i] <= '9') - num = a[i] - '0'; - else if (a[i] >= 'A' && a[i] <= 'F') - num = a[i] - 'A' + 10; - sum = sum * B + num; - } - return sum; -} -void Numchange(int m, int B) -{ - int n; - if (m) - { - Numchange(m / B, B); - n = m % B; - if (n < 10) - printf("%d", n); //小于10直接输出 - else - printf("%c", n + 55); //大于10转换成字符输出 - } -} -int main() -{ - int B, b; - char a[20]; - printf("请输入待转换数的进制(2-16):"); - do - { - scanf("%d", &B); - } - while (B < 2 && B > 16); - printf("请输入待转换数:"); - getchar(); - gets(a); //将输入的n进制数存放在数组a中 - int m = TenNum(a, B); //将输入的数字转换成十进制数 - printf("请输入需要转成几进制数(2-16):"); - do - { - scanf("%d", &b); - } while (B < 2 && B > 16); - printf("%d进制数%s转换为%d进制数的结果为:",B,a,b); - Numchange(m, b); //将十进制数转换为所需进制数 - printf("\n"); - system("pause"); - return 0; -} - -