1.c����������� Դ��
2.C语言程序设计:c=m!/(n!*(m-n)!)
3..cs是程程序什么文件
4.有没有300行左右的C语言课程设计的源代码
5.c语言中. c文件是什么?
c����������� Դ��
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* Define constants for the calculator */
#define UP 0x
#define DOWN 0x
#define LEFT 0x4B
#define RIGHT 0x4D
#define ENTER 0x0D
/* Global variables */
double num1 = 0, num2 = 0, result = 0;
char str1[] = ".+-*/知消扒Qc=^%";
char cnum[5], str2[] = "", c;
int x, y, x0, y0, i, j, v, m, n, act, flag = 1;
/* Function prototypes */
void drawboder(void);
void initialize(void);
void computer(void);
void changetextstyle(int font, int direction, int charsize);
void mwindow(char *header);
int specialkey(void);
int arrow();
/* Main function */
int main() {
initialize();
computer();
closegraph();
return 0;
}
/* Initialize the graphics system */
void initialize(void) {
int xasp, yasp;
GraphDriver = DETECT;
initgraph( &GraphDriver, &GraphMode, "" );
ErrorCode = graphresult();
if (ErrorCode != grOk) {
printf("Graphics System Error: %s\n", grapherrormsg(ErrorCode));
exit(1);
}
getpalette( &palette );
MaxColors = getmaxcolor() + 1;
MaxX = getmaxx();
MaxY = getmaxy();
getaspectratio( &xasp, &yasp );
AspectRatio = (double)xasp / (double)yasp;
}
/* Main calculator function */
void computer(void) {
struct viewporttype vp;
int color, height, width;
mwindow("Calculator");
color = 7;
getviewsettings( &vp );
width = (vp.right + 1) / ;
height = (vp.bottom - ) / ;
x = width / 2;
y = height / 2;
setfillstyle(SOLID_FILL, color + 3);
bar( x + width * 2, y, x + 7 * width, y + height );
setcolor( color + 3 );
rectangle( x + width * 2, y, x + 7 * width, y + height );
setcolor(RED);
outtextxy(x + 3 * width, y + height / 2, "0.");
x = 2 * width - width / 2;
y = 2 * height + height / 2;
for (j = 0; j < 4; ++j) {
for (i = 0; i < 5; ++i) {
setfillstyle(SOLID_FILL, color);
setcolor(RED);
bar( x, y, x + width, y + height );
rectangle( x, y, x + width, y + height );
sprintf(str2, "%c", str1[j * 5 + i]);
outtextxy( x + (width / 2), y + height / 2, str2);
x += width + (width / 2);
}
y += (height / 2) * 3;
x = 2 * width - width / 2;
}
x0 = 2 * width;
y0 = 3 * height;
x = x0;
y = y0;
gotoxy(x, y);
arrow();
m = 0;
n = 0;
strcpy(str2, "");
while ((v = specialkey()) != ) {
while ((v = specialkey()) != ENTER) {
putimage(x, y, rar, XOR_PUT);
if (v == RIGHT) {
if (x >= x0 + 6 * width)
x = x0;
else
x += width + width / 2;
m++;
}
if (v == LEFT) {
if (x <= x0)
x = x0 + 6 * width;
else
x -= width - width / 2;
m--;
}
if (v == UP) {
if (y <= y0)
y = y0 + 4 * height + height / 2;
else
y -= height - height / 2;
n--;
}
if (v == DOWN) {
if (y >= 7 * height)
y = y0;
else
y += height + height / 2;
n++;
}
putimage(x, y, rar, XOR_PUT);
}
c = str1[n * 5 + m];
if (isdigit(c) || c == '.') {
if (flag == -1) {
strcpy(str2, "-");
flag = 1;
}
sprintf(temp, "%c", c);
strcat(str2, temp);
setfillstyle(SOLID_FILL, color + 3);
bar(2 * width + width / 2, height / 2, * width / 2, 3 * height / 2);
outtextxy(5 * width, height, str2);
}
if (c == '+') {
num1 = atof(str2);
strcpy(str2, "");
act = 1;
setfillstyle(SOLID_FILL, color + 3);
bar(2 * width + width / 2, height / 2, * width / 2, 3 * height / 2);
outtextxy(5 * width, height, "0.");
}
if (c == '-') {
if (strcmp(str2, "") == 0)
flag = -1;
else {
num1 = atof(str2);
strcpy(str2, "");
act = 2;
setfillstyle(SOLID_FILL, color + 3);
bar(2 * width + width / 2, height / 2, * width / 2, 3 * height / 2);
outtextxy(5 * width, height, "0.");
}
}
if (c == '*') {
num1 = atof(str2);
strcpy(str2, "");
act = 3;
setfillstyle(SOLID_FILL, color + 3);
bar(2 * width + width / 2, height / 2, * width / 2, 3 * height / 2);
outtextxy(5 * width, height, "0.");
}
if (c == '/') {
num1 = atof(str2);
strcpy(str2, "");
act = 4;
setfillstyle(SOLID_FILL, color + 3);
bar(2 * width + width / 2, height / 2, * width / 2, 3 * height / 2);
outtextxy(5 * width, height, "0.");
}
if (c == '^') {
num1 = atof(str2);
strcpy(str2, "");
act = 5;
setfillstyle(SOLID_FILL, color + 3);
bar(2 * width + width / 2, height / 2, * width / 2, 3 * height / 2);
outtextxy(5 * width, height, "0.");
C语言程序设计:c=m!/(n!*(m-n)!)
C(n,m)=n!/(m!*(n-m)!),C(n,序设m)=p1a1-b1-c1p2a2-b2-c2…pkak-bk-ck,n<=,,[cpp]
#include<cstdio>
constintmaxn=;
#include<vector>
usingnamespacestd;
boolarr[maxn+1]={ false};
vector<int>produce_prim_number()
{
vector<int>prim;
prim.push_back(2);
inti,j;
for(i=3;i*i<=maxn;i+=2)
{
if(!arr[i])
{
prim.push_back(i);
for(j=i*i;j<=maxn;j+=i)
arr[j]=true;
}
}
while(i<maxn)
{
if(!arr[i])
prim.push_back(i);
i+=2;
}
returnprim;
}
//计算n!中素数因子p的指数
intcal(intx,intp)
{
intans=0;
longlongrec=p;
while(x>=rec)
{
ans+=x/rec;
rec*=p;
}
returnans;
}
//计算n的k次方对m取模,二分法
intpow(longlongn,计语intk,intM)
{
longlongans=1;
while(k)
{
if(k&1)
{
ans=(ans*n)%M;
}
n=(n*n)%M;
k>>=1;
}
returnans;
}
//计算C(n,m)
intcombination(intn,言源语言源码android源码关机闹铃intm)
{
constintM=;
vector<int>prim=produce_prim_number();
longlongans=1;
intnum;
for(inti=0;i<prim.size()&&prim[i]<=n;++i)
{
num=cal(n,prim[i])-cal(m,prim[i])-cal(n-m,prim[i]);
ans=(ans*pow(prim[i],num,M))%M;
}
returnans;
}
intmain()
{
intm,n;
while(~scanf("%d%d",&m,&n),m&&n)
{
printf("%d\n",combination(m,n));
}
return0;
}
扩展资料
C语言N项规律数和
#include"stdio.h"
#include"stdlib.h"
main()
{
intk=1,m=2;
intn,i,j;
scanf("%4d",&n);
j=1;
printf("%4d",k);
for(i=1;i<n;i++)
{
if(k==m)
{
j=-1;
m=m+1;
}
elseif(k==1)
{
j=1;
k=k+j;
printf("%4d",k);
}
printf("\n");
}
}
.cs是什么文件
.cs是C Sharp程序设计语言的源代码文件。它是设计一种微软主推的面向对象的高级编程语言,拥有同Java类似的程程序语法和使用方式,但是序设主要是在微软全家桶上开发并编译的,依赖的计语环境也主要是微软的.net。C Sharp编写的言源语言源码程序,其源文件拓展名就是设计.cs,可以用它来编译可执行程序。程程序fastclick源码解析其旨在设计成为一种“简单、序设现代、计语通用”,言源语言源码以及面向对象的设计程序设计语言。软件必须做到强大、tftp client 源码持久,并具有较强的编程生产力。
C#是由C和C++衍生出来的一种安全的、稳定的、简单的vuex源码解析、优雅的面向对象编程语言。它在继承C和C++强大功能的同时去掉了一些它们的复杂特性(例如没有宏以及不允许多重继承)。C#综合了VB简单的可视化操作和C++的高运行效率,以其强大的操作能力、优雅的widyphp源码下载语法风格、创新的语言特性和便捷的面向组件编程的支持成为.NET开发的首选语言。
C#是面向对象的编程语言。它使得程序员可以快速地编写各种基于MICROSOFT .NET平台的应用程序,MICROSOFT .NET提供了一系列的工具和服务来最大程度地开发利用计算与通讯领域。
C#使得C++程序员可以高效的开发程序,且因可调用由 C/C++ 编写的本机原生函数,而绝不损失C/C++原有的强大的功能。因为这种继承关系,C#与C/C++具有极大的相似性,熟悉类似语言的开发者可以很快的转向C#。
有没有行左右的C语言课程设计的源代码
#include <stdio.h>
#include <stdlib.h>
#include "windows.h"
#include "string.h"
#define S_MAX
int user_count=0; //用户信息的总数
int book_count=0;
char ini_path[]={ "\0"}; //数据文件的绝对路径
char user_path[]={ "\0"}; //用户数据文件的绝对路径
char book_path[]={ "\0"};
int book_pos=0; //book数组的计数
int user_pos=0;
struct user_data
{
char name[];
char book_name[];
}user[S_MAX];
struct book_data
{
char no[];
char name[];
char author[];
char money[];
char in_or_out[];
char user_name[];
}book[S_MAX];
void read_file() //从文件读取数据
{
user_pos=0;
int i;
for(i=0;i<S_MAX;i++)
{
memset(user[i].name,'\0',);
memset(user[i].book_name,'\0',);
memset(book[i].no,'\0',);
memset(book[i].name,'\0',);
memset(book[i].author,'\0',);
memset(book[i].money,'\0',);
memset(book[i].in_or_out,'\0',);
memset(book[i].user_name,'\0',);
}
user_count=GetPrivateProfileInt("USER","user_count",0,user_path);
book_count=GetPrivateProfileInt("book","book_count",0,book_path);
for(i=0;i<user_count;i++)
{
char t[5]={ "\0"};
sprintf(t,"%d",i+1);
GetPrivateProfileString(t,"name","",user[i].name,,user_path);
GetPrivateProfileString(t,"book_name","",user[i].book_name,,user_path);
user_pos++;
}
for(i=0;i<book_count;i++)
{
char t[5]={ "\0"};
sprintf(t,"%d",i+1);
GetPrivateProfileString(t,"no","",book[i].no,,book_path);
GetPrivateProfileString(t,"name","",book[i].name,,book_path);
GetPrivateProfileString(t,"author","",book[i].author,,book_path);
GetPrivateProfileString(t,"money","",book[i].money,,book_path);
GetPrivateProfileString(t,"in_or_out","",book[i].in_or_out,,book_path);
GetPrivateProfileString(t,"user_name","",book[i].user_name,,book_path);
book_pos++;
}
}
void write_file()
{
int i;
for(i=0;i<user_count;i++)
{
char t[5]={ "\0"};
sprintf(t,"%d",i+1);
WritePrivateProfileString(t,"name",NULL,user_path);
WritePrivateProfileString(t,"book_name",NULL,user_path);
WritePrivateProfileString(t,"no",NULL,book_path);
WritePrivateProfileString(t,"name",NULL,book_path);
WritePrivateProfileString(t,"author",NULL,book_path);
WritePrivateProfileString(t,"money",NULL,book_path);
WritePrivateProfileString(t,"in_or_out",NULL,book_path);
WritePrivateProfileString(t,"user_name",NULL,book_path);
}
char temp[5]={ "\0"};
int temp_count=0;
for(i=0;i<user_pos;i++)
{
if(strcmp(user[i].name,"")==0)
{
continue;
}
char t[5]={ "\0"};
sprintf(t,"%d",i+1);
WritePrivateProfileString(t,"name",user[i].name,user_path);
WritePrivateProfileString(t,"book_name",user[i].book_name,user_path);
temp_count++;
}
sprintf(temp,"%d",temp_count);
WritePrivateProfileString("USER","user_count",temp,user_path);
temp_count=0;
for(i=0;i<book_pos;i++)
{
if(strcmp(book[i].no,"")==0)
{
continue;
}
char t[5]={ "\0"};
sprintf(t,"%d",i+1);
WritePrivateProfileString(t,"no",book[i].no,book_path);
WritePrivateProfileString(t,"name",book[i].name,book_path);
WritePrivateProfileString(t,"author",book[i].author,book_path);
WritePrivateProfileString(t,"money",book[i].money,book_path);
WritePrivateProfileString(t,"in_or_out",book[i].in_or_out,book_path);
WritePrivateProfileString(t,"user_name",book[i].user_name,book_path);
temp_count++;
}
sprintf(temp,"%d",temp_count);
WritePrivateProfileString("BOOK","book_count",temp,book_path);
}
void search_user_name() //按借书人姓名查询
{
system("cls");
char search_key[]={ "\0"};
printf("请输入要查询图书借书人:");
scanf("%s",search_key);
int i;
int s[]={ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int s_i=0;
int find=0;
for(i=0;i<book_pos;i++)
{
if(strcmp(book[i].user_name,search_key)==0)
{
find=1;
s[s_i]=i;
s_i++;
printf("\n编 号: %s",book[i].no);
printf("\n名 称: %s",book[i].name);
printf("\n作 者: %s",book[i].author);
printf("\n金 额: %s",book[i].money);
printf("\n状 态: %s",book[i].in_or_out);
printf("\n借 书 人: %s\n",book[i].user_name);
}
}
if(find==0)
{
printf("\n\n未找到符合条件的信息!");
}
else
{
for(i=0;i<s_i;i++)
{
printf("\n\n第%d本书: %s",i+1,book[i].name);
}
printf("\n\n共%d本",i);
}
fflush(stdin);
getchar();
}
void search_book_author() //按图书作者查询
{
system("cls");
char search_key[]={ "\0"};
printf("请输入要查询图书的作者:");
scanf("%s",search_key);
int i;
int find=0;
for(i=0;i<book_pos;i++)
{
if(strcmp(book[i].author,search_key)==0)
{
find=1;
printf("\n编 号: %s",book[i].no);
printf("\n名 称: %s",book[i].name);
printf("\n作 者: %s",book[i].author);
printf("\n金 额: %s",book[i].money);
printf("\n状 态: %s",book[i].in_or_out);
printf("\n借 书 人: %s\n",book[i].user_name);
break;
}
}
if(find==0)
{
printf("\n\n未找到符合条件的信息!");
}
fflush(stdin);
getchar();
}
void search_book_name() //按图书名称查询
{
system("cls");
char search_key[]={ "\0"};
printf("请输入要查询图书的名称:");
scanf("%s",search_key);
int i;
int find=0;
for(i=0;i<book_pos;i++)
{
if(strcmp(book[i].name,search_key)==0)
{
find=1;
printf("\n编 号: %s",book[i].no);
printf("\n名 称: %s",book[i].name);
printf("\n作 者: %s",book[i].author);
printf("\n金 额: %s",book[i].money);
printf("\n状 态: %s",book[i].in_or_out);
printf("\n借 书 人: %s\n",book[i].user_name);
break;
}
}
if(find==0)
{
printf("\n\n未找到符合条件的信息!");
}
fflush(stdin);
getchar();
}
void search_book_no() //按图书编号查询
{
system("cls");
char search_key[]={ "\0"};
printf("请输入要查询图书的编号:");
scanf("%s",search_key);
int i;
int find=0;
for(i=0;i<book_pos;i++)
{
if(strcmp(book[i].no,search_key)==0)
{
find=1;
printf("\n编 号: %s",book[i].no);
printf("\n名 称: %s",book[i].name);
printf("\n作 者: %s",book[i].author);
printf("\n金 额: %s",book[i].money);
printf("\n状 态: %s",book[i].in_or_out);
printf("\n借 书 人: %s\n",book[i].user_name);
break;
}
}
if(find==0)
{
printf("\n\n未找到符合条件的信息!");
}
fflush(stdin);
getchar();
}
void search_all_book() //查询所有图书
{
system("cls");
if(book_pos==0)
{
printf("真TM穷,一本书都没有");
}
else
{
int i;
printf("共有%d本书\n",book_pos);
for(i=0;i<book_pos;i++)
{
printf("\n编号:%s 名称:%s 作者:%s 金额:%s 状态:%s",book[i].no,book[i].name,book[i].author,book[i].money,book[i].in_or_out);
if(strcmp(book[i].in_or_out,"out")==0)
{
printf(" 借书人:%s",book[i].user_name);
}
}
}
fflush(stdin);
getchar();
}
void search_all_user() //查询所有用户
{
system("cls");
if(user_pos==0)
{
printf("要倒闭了?一个人都没有!");
}
else
{
int i;
printf("共有%d个用户\n",user_pos);
for(i=0;i<user_pos;i++)
{
printf("\n用户名称: %s 借书名称: ",user[i].name);
if(strcmp(user[i].book_name,"")!=0)
{
printf("%s",user[i].book_name);
}
else
{
printf("未借书");
}
}
}
fflush(stdin);
getchar();
}
void No7() //查询
{
int f=1;
int sel;
while(f)
{
system("cls");
printf("