c语言趣味代码

“c语言趣味代码”相关的资料有哪些?“c语言趣味代码”相关的范文有哪些?怎么写?下面是小编为您精心整理的“c语言趣味代码”相关范文大全或资料大全,欢迎大家分享。

c语言趣味题

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

C/C++语言经典、实用、趣味程序设计编程百例精解

1.绘制余弦曲线

在屏幕上用―*‖显示0~360度的余弦函数cos(x)曲线 *问题分析与算法设计

如果在程序中使用数组,这个问题十分简单。但若规定不能使用数组,问题就变得不容易了。 关键在于余弦曲线在0~360度的区间内,一行中要显示两个点,而对一般的显示器来说,只能按行输出,即:输出第一行信息后,只能向下一行输出,不能再返回到上一行。为了获得本文要求的图形就必须在一行中一次输出两个―*‖。

为了同时得到余弦函数cos(x)图形在一行上的两个点,考虑利用cos(x)的左右对称性。将屏幕的行方向定义为x,列方向定义为y,则0~180度的图形与180~360度的图形是左右对称的,若定义图形的总宽度为62列,计算出x行0~180度时y点的坐标m,那么在同一行与之对称的180~360度的y点的坐标就 应为62-m。程序中利用反余弦函数acos计算坐标(x,y)的对应关系。

使用这种方法编出的程序短小精炼,体现了一定的技巧。 *程序说明与注释 #include #include int main() {

double y; int x,m;

for(y=1;y>=-1;y-=0.1) /*y

c语言源代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

acm经典百题

#include int main( )1088 阶乘求和 { int ncase,n, i,j; long sum,t; scanf("%d", &ncase); for(i=0;i #include main() 1108 {int n; 单词缩写月份的英文缩 写 while(scanf("%d\n",&n)!=EOF& &n>0&&n<=12) {if(n==1)printf("Jan\n"); else if(n==2)printf("Feb\n"); else if(n==3)printf("Mar\n"); else if(n==4)printf("Apr\n"); else if(n==5)printf("May\n"); else if(n==6)printf("June\n"); else if(n==7)printf("July\n

C语言2048源代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

#include #include #include #include #define N 4

void Generat_picture(int d[N][N],char c[N][N][N],int s); void Control_synthesis(int a[N][N]); void add_num(int a[N][N]); void swap(int *a,int *b); int score(int a[N][N]); int moveup(int a[N][N]); int movedown(int a[N][N]); int moveleft(int a[N][N]); int moveright(int a[N][N]); int main() {

int d[N][N]; char c[N][N][N]; int i,j,s=2; system(\ for(i=0; i

add_num(d);

Generat_picture(d,c,s); Control_synthesis(d); s=score(d);

C语言串口通信-源代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

C语言串口通信-源代码

#include <stdio.h>

#include <dos.h>

#include <conio.h>

#include <string.h>

#define COM232 0x2f8

#define COMINT 0x0b

#define MaxBufLen 500

#define Port8259 0x20

#define EofInt 0x20

static int comportaddr;

static char intvectnum;

static unsigned char maskb;

static unsigned char Buffer[MaxBufLen];

static int CharsInBuf,CircIn,CircOut;

static void (interrupt far *OldAsyncInt)();

static void interrupt far AsyncInt(void);

void Init_COM(int ComPortAddr, unsigned char IntVectNum, int Baud,

un

MODBUS通讯+C语言源代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

MODBUS通讯+C语言源代码

/*********************************************************************************/

/*函数名称: strmcpy()

*输入参数: 共 个参数;

*输出参数: 共 个参数;

*返回值:

*需储存的参数: 共 个参数;

*功能介绍:

(1)字符数组拷贝;

*修改日志:

*[2006-3-6 17:07] Ver. 1.00

开始编写;

完成;

/* */

/*********************************************************************************/

void strmcpy(unsigned char dest[], unsigned char src[], int count) {

int i;

for(i = 0; i < count; i ++)

{

dest[i] = src[i];

}

dest[i] = '\0';

}

/**************************************

贪吃蛇代码(C语言)

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

//2010.06.09
//zook0k
///zook0k/
//
//
//qq:83310093

#include <windows.h>
#include <stdio.h>
#include<time.h>

#define C_W 516
#define C_H 548
//#define C_W 1024
//#define C_H 1024

#define GO_RIGHT 0x01
#define GO_DOWN 0x02
#define GO_LEFT 0x03
#define GO_UP 0x04


#define SNAKE_NUMBER 30
typedef struct node_struct
{
unsigned char direction;
unsigned char cnt;
}s_node,*s_node_handle;
s_node s_count[SNAKE_NUMBER ];

typedef struct SNAKE
{
unsigned char Head_X;
unsigned char Head_Y;
unsigned char Tail_X;
unsigned char Tail_Y;

C语言数据结构+代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

学院

计算机科学系

数据结构课程设计报告

设计名称: 压缩器/解压器 姓 名: 学 号:

专业班级: 08软件技术(1)班 系 (院): 计算机科学系 设计时间: 2009~2010学年第二学期 设计地点: 六楼机房

目 录

一 需求分析----------------------------------------------------------------------------------------3 二 概要设计----------------------------------------------------------------------------------------3 三 详细设计----------------------------------------------------------------------------------------6 四 测试与分析-----------------

学生管理系统 c语言源代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

学生管理系统 c语言源代码

#include <stdio.h>

#include <dos.h>

#include <string.h>

#include <stdlib.h>

#include <malloc.h>

#define SIZE 8

struct student

{

char name[20];

char num[15];

int score[5];

float ave;

struct student *next;

}stu[SIZE],temp,s;

void shuru()

{

int i,j,sum,length,flag=1,a;

FILE *fp;

while(flag==1)

{

printf("Define a range>class number:");

scanf("%d",&a);

printf("Input the total number of the class(<a):");

scanf("%d",&length);

if(length<a)

flag=0;

}

for(i=0;i

C语言编写象棋程序代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

可编辑/*--------------------chess.c----------------------*/

#include "dos.h"

#include "stdio.h"

/*----------------------------------------------------*/

#define RED 7

#define BLACK 14

#define true 1

#define false 0

#define SELECT 0

#define MOVE 1

#define RED_UP 0x1100

#define RED_DOWN 0x1f00

#define RED_LEFT 0x1e00

#define RED_RIGHT 0x2000

#define RED_DO 0x3900

#define RED_UNDO 0x1000

#define BLACK_UP 0x4800

#define BLACK_DOWN 0x5000

#define BLACK_LEFT 0x4b00

#define BLACK_RIGHT 0x4d00

#define BLACK_DO 0x1c00

#define BLACK_UNDO

c语言实现远程关机代码

标签:文库时间:2024-09-11
【bwwdw.com - 博文网】

#include #include #include int print() {

printf(\★★★★★★★★★★★★★★★★★★★★★★★★★★★★★\\n\ printf(\

printf(\◆◆◆◆◆◆◆◆关机软件◆◆◆◆◆◆ ◆◆\\n\ printf(\◆◆ 1.实现10分钟内的定时关闭计算机 ◆◆\\n\ printf(\◆◆ 2.立即关闭计算机 ◆◆\\n\ printf(\◆◆ 3.注销计算机 ◆◆\\n\ printf(\◆◆ 4.关闭并重启计算机 ◆◆\\n\ printf(\◆◆ 5.休眠计算机 ◆◆\\n\ printf(\◆◆ 6.远程目标计算机重启 ◆◆\\n\ printf(\◆◆ 7.远程目标计算机关闭 ◆◆\\n\ printf(\◆◆ 8.退出系统 ◆◆\\n\ printf(\◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆ ◆◆\\n\ printf(\

print