2013年第四届蓝桥杯全国软件大赛C/C++预赛试题(C/C++本科B组)
包含11个文件.其中10个试题文件,1个说明文件:
1.高斯日记(4分).txt
2.马虎的算式(5分).txt
3.第39级台阶(8分).txt
4.黄金连分数(12分).txt
5.前缀判断(5分).txt
6.三部排序(7分).txt
7.错误票据(4分).txt
8.翻硬币(10分).txt
9.带分数(16分).txt
10.连号区间数(29分).txt
说明.docx
1.高斯日记(4分).txt
大数学家高斯有个好习惯:无论如何都要记日记。
他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210
后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?
高斯出生于:1777年4月30日。
在高斯发现的一个重要定理的日记上标注着:5343,因此可算出那天是:1791年12月15日。
高斯获得博士学位……
写的很好的C++控制台俄罗斯方块
/*
Author : 周天涯
email : menjitianya2007@163.com
blog : http://www.cppblog.com/menjitianya/
Description : 即兴创作,《C控制台 俄罗斯方块》,欢迎交流与探讨,直接将代码粘贴到VC6.0的环境下即可运行。
← 左移
→ 右移
↓ 加速
↑ 旋转
连续消去1行得1分、2行得3分、3行得5分、4行得7分。
积分达到一定程度,会有换命的活动,命最多6条。
难度会随积分的上升逐渐上升,最多到6的难度。
*/
#include <iostream>
#include <windows.h>
#include <vector>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
using namespace std;
#define GameW 10
#define GameH 20
const int CtrlLeft = GameW*2+4 + 3;
struct Point {
Point(){}
Point(int x, int y) {_x = x, _y = y;}
int _x, _y;
};
HANDLE g_hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE g_hInput = GetStdHandle(STD_INPUT_HANDLE);
通信录管理程序(升级版)
升级前的程序:http://download.csdn.net/detail/wennfengg/436458
下面是前n行代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct person
{
char name[20];
char phone[20];
char address[50];
};
struct person_link
{
char name[20];
char phone[20];
char address[50];
struct person_link *next;
}*head=NULL;
FILE *fp;
void slow2() //减速。使程序运行速度减慢,以达到特殊效果。
{
int i;
for(i=0;i<100000000;i++)
{
}
return;
}
void slow() //减速。减速程度比slow2大。
{
int i;
for(i=0;i<500000000;i++)
{
}
return;
}
void read_tonxinlu() //读取文件"tonxinlu"中的数据,以建立链表
{
struct person information;
struct person_link *news,*t=NULL;
if((fp=fopen("通信录","ab+"))==NULL)
{
printf("打开通信录失败");
exit(0);
通信录管理程序
程序共172行代码
适合初学者,因为这程序是我在初学C时写的
另外我还对这个程序升了级,升级后功能更丰富,“界面”更友好。
若需要这个升级后的代码,请在CSDN搜索:“通信录管理程序(升级版)”
下面是前n行代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct person
{
char name[20];
char phone[20];
char address[50];
};
struct person_link
{
char name[20];
char phone[20];
char address[50];
struct person_link *next;
}*head=NULL;
FILE *fp;
void read_tonxinlu() //读取文件"tonxinlu"中的数据,以建立链表
{
struct person information;
struct person_link *news,*t=NULL;
if((fp=fopen("tonxinlu","ab+"))==NULL)
{
printf("打开通信录失败");
exit(0);
}
while(fread(&information;,sizeof(struct person),1,fp)==1)
{
if((news=(struct person_link*)malloc(sizeof(struct person_link)))==NULL)
{
printf("内存分配失败");
exit(0);
}
news->next=NULL;
strcpy(news->name,information.name);
strcpy(news->phone,information.phone);
strcpy(news->address,information.address);
head=news; //将新建的结构体插入链表的第一个节点
head->next=t;
t=head;
}
fclose(fp);
}
void insert() //新建联系人
{
贪吃蛇 控制台程序
开头n行代码:
#include<iostream>
#include<time.h>
#include<conio.h>
#include<windows.h>
#include<stdlib.h>
using namespace std;
struct she //用x,y记录蛇的坐标
{
int x;
int y;
struct she *next;
}*tou,*wei; //分别指向表示蛇头,蛇尾的节点
enum fangxiang //方向
{shang='w',xia='s',zuo='a',you='d'};
int changdu=5;//蛇的长度
bool shibai=false;
char zuobiao[22][22]; //用二维数组记录游戏画面的信息
//将二维数组zuobiao中的信息显示在屏幕上
void xianshi()
{
system("cls");
cout<<"\t\t你的长度是:"<<changdu;
cout<<"\t\t你的等级是:"<<changdu/10<<endl;
for(int i=0;i<21;i++)
{
cout<<"\t\t";
for (int j=0;j<21;j++)
{
cout<<zuobiao[i][j]<<' ';
}
cout<<endl;
}
}