1.用C语言写的源码计算器源代码
2.求C++电话薄源代码
3.为å¥Androidä¸ç¨å°ç.cppä¸çsizeof(wchar_t)å ç¨å个åè
用C语言写的计算器源代码
#include<stdio.h>
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
typedef float DataType;
typedef struct
{
DataType *data;
int max;
int top;
}Stack;
void SetStack(Stack *S,int n)
{
S->data=(DataType*)malloc(n*sizeof(DataType));
if(S->data==NULL)
{
printf("overflow");
exit(1);
}
S->max=n;
S->top=-1;
}
void FreeStack(Stack *S)
{
free(S->data);
}
int StackEmpty(Stack *S)
{
if(S->top==-1)
return(1);
return(0);
}
DataType Peek(Stack *S)
{
if(S->top==S->max-1)
{
printf("Stack is empty!\n");
exit(1);
}
return(S->data[S->top]);
}
void Push(Stack *S,DataType item)
{
if(S->top==S->max-1)
{
printf("Stack is full!\n");
exit(1);
}
S->top++;
S->data[S->top]=item;
}
DataType Pop(Stack *S)
{
if(S->top==-1)
{
printf("Pop an empty stack!\n");
exit(1);
}
S->top--;
return(S->data[S->top+1]);
}
typedef struct
{
char op;
int inputprecedence;
int stackprecedence;
}DataType1;
typedef struct
{
DataType1 *data;
int max;
int top;
}Stack1;
void SetStack1(Stack1 *S,int n)
{
S->data=(DataType1*)malloc(n*sizeof(DataType1));
if(S->data==NULL)
{
printf("overflow");
exit(1);
}
S->max=n;
S->top=-1;
}
void FreeStack1(Stack1 *S)
{
free(S->data);
}
int StackEmpty1(Stack1 *S)
{
if(S->top==-1)
return(1);
return(0);
}
DataType1 Peek1(Stack1 *S)
{
if(S->top==S->max-1)
{
printf("Stack1 is empty!\n");
exit(1);
}
return(S->data[S->top]);
}
void Push1(Stack1 *S,DataType1 item)
{
if(S->top==S->max-1)
{
printf("Stack is full!\n");
exit(1);
}
S->top++;
S->data[S->top]=item;
}
DataType1 Pop1(Stack1 *S)
{
if(S->top==-1)
{
printf("Pop an empty stack!\n");
exit(1);
}
S->top--;
return(S->data[S->top+1]);
}
DataType1 MathOptr(char ch)
{
DataType1 optr;
optr.op=ch;
switch(optr.op)
{
case'+':
case'-':
optr.inputprecedence=1;
optr.stackprecedence=1;
break;
case'*':
case'/':
optr.inputprecedence=2;
optr.stackprecedence=2;
break;
case'(':
optr.inputprecedence=3;
optr.stackprecedence=-1;
break;
case')':
optr.inputprecedence=0;
optr.stackprecedence=0;
break;
}
return(optr);
}
void Evaluate(Stack *OpndStack,DataType1 optr)
{
DataType opnd1,opnd2;
opnd1=Pop(OpndStack);
opnd2=Pop(OpndStack);
switch(optr.op)
{
case'+':
Push(OpndStack,opnd2+opnd1);
break;
case'-':
Push(OpndStack,opnd2-opnd1);
break;
case'*':
Push(OpndStack,opnd2*opnd1);
break;
case'/':
Push(OpndStack,opnd2/opnd1);
break;
}
}
int isoptr(char ch)
{
if(ch=='+'||ch=='-'||ch=='*'||ch=='/'||ch=='(')
return(1);
return(0);
}
void Infix(char *str)
{
int i,k,n=strlen(str);
char ch,numstr[];
DataType opnd;
DataType1 optr;
Stack OpndStack;
Stack1 OptrStack;
SetStack(&OpndStack,n);
SetStack1(&OptrStack,n);
k=0;
ch=str[k];
while(ch!='=')
if(isdigit(ch)||ch=='.')
{
for(i=0;isdigit(ch)||ch=='.';i++)
{
numstr[i]=ch;
k++;
ch=str[k];
}
numstr[i]='\0';
opnd= atof(numstr);
Push(&OpndStack,opnd);
}
else
if(isoptr(ch))
{
optr=MathOptr(ch);
while(Peek1(&OptrStack).stackprecedence>=optr.inputprecedence)
Evaluate(&OpndStack,Pop1(&OptrStack));
Push1(&OptrStack,optr);
k++;
ch=str[k];
}
else if(ch==')')
{
optr=MathOptr(ch);
while(Peek1(&OptrStack).stackprecedence>=optr.inputprecedence)
Evaluate(&OpndStack,Pop1(&OptrStack));
Pop1(&OptrStack);
k++;
ch=str[k];
}
while(!StackEmpty1(&OptrStack))
Evaluate(&OpndStack,Pop1(&OptrStack));
opnd=Pop(&OpndStack);
cout<<"你输入表达式的计算结果为"<<endl;
printf("%-6.2f\n",opnd);
FreeStack(&OpndStack);
FreeStack1(&OptrStack);
}
void main()
{
cout<<"请输入你要计算的表达式,并以“=”号结束。"<<endl;
char str[];
gets(str);
Infix(str);
=================================================================
哈哈!源码广告分红app源码给分吧!源码准点学车源码
求C++电话薄源代码
部分能满足你的源码量化开仓源码要求
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <windows.h>
#include <winbase.h>
typedef struct node{ /* 定义链表 */
char name[]; /* 姓名 */
char address[]; /* 地址 */
char phone[]; /* 电话 */
long zip; /* 邮编 */
struct node *next;
}add_list;
struct person{ /* 定义一个结构备用 */
char name[];
char address[];
char phone[];
long zip;
};
FILE *fp;
add_list *tail,*head; /* 定义链表尾节点指针和头指针 */
/* 从文件中读出数据生成通讯录链表,如果文件不存在,生成空链表 */
add_list *load(char filename[])
{ add_list *new1,*head;
struct person t;
head=(add_list *)malloc(sizeof(add_list));
tail=head=NULL;
if((fp=fopen(filename,"rb"))==NULL)
return head;
else
if(!feof(fp))
if(fread(&t,sizeof(struct person),1,fp)==1)
{ new1=(add_list *)malloc(sizeof(add_list)); /* 连入链表第一个节点 */
strcpy(new1->name,t.name);
strcpy(new1->address,t.address);
strcpy(new1->phone,t.phone);
new1->zip=t.zip;
head=tail=new1;
new1->next=NULL;
while(!feof(fp)) /* 连入链表其余节点 */
{ if(fread(&t,sizeof(struct person),1,fp)==1)
{ new1=(add_list *)malloc(sizeof(add_list));
strcpy(new1->name,t.name);
strcpy(new1->address,t.address);
strcpy(new1->phone,t.phone);
new1->zip=t.zip;
tail->next=new1;
new1->next=NULL;
tail=new1;
}
}
}
fclose(fp);
return head;
}
/* 自定义函数 */
/* 娱乐一下先 */
void jindutiao(void)
{ int i;
for(i=0;i<;i++) putchar('.');
printf("\r\a");
for(i=0;i<;i++)
{
if(i==0) putchar('|');
Sleep();
printf("\b|>");
}
}
/* 插入一条通讯录记录 */
void insert(add_list **head)
{ add_list * new1;
new1=(add_list *)malloc(sizeof(add_list));
system("cls");
printf("\n请输入姓名:"); getchar();gets(new1->name);
printf("\n请输入地址:"); scanf("%s",new1->address);
printf("\n请输入电话:"); scanf("%s",new1->phone);
printf("\n请输入邮编:"); scanf("%ld",&new1->zip);
if(*head==NULL) /* 表头为空时 */
{ *head=new1;
new1->next=NULL;
tail=new1;
}
else /* 插入到表尾 */
{ tail->next=new1;
new1->next=NULL;
tail=new1;
}
printf("输入完成,按回车键返回......");
getchar();
getchar();
}
/* 将通讯录链表中的内容保存到指定文件中 */
void save(add_list *head,char filename[])
{ add_list *p;
struct person t;
if((fp=fopen(filename,"wb"))==NULL)
{ printf("错误:不能打开文件%s\n",filename);
exit(1);
}
else
{ p=head;
while(p!=NULL)
{ strcpy(t.name,p->name);
strcpy(t.address,p->address);
strcpy(t.phone,p->phone);
t.zip=p->zip;
fwrite(&t,sizeof(struct person),1,fp);
p=p->next;
}
}
fclose(fp);
printf("保存成功,按回车键返回......");
getchar();getchar();
}
/* 显示通讯录内容 */
void display(add_list *head)
{ add_list *p;
p=head;
if(p!=NULL)
printf("姓名:\t\t住址:\t\t邮编:\t\t电话:\n");
while(p!=NULL)
{
printf("%s\t\t%s\t\t%ld\t\t%s\n",p->name,p->address,p->zip,p->phone);
p=p->next;
}
printf("按回车键返回......");
getchar();getchar();
}
/* 按姓名查询通讯录记录 */
int search(add_list *head)
{ add_list *p;
char name[];
int flag=0;
printf("请输入要查找的人的姓名:");
getchar();
gets(name);
p=head;
while(p!=NULL)
{ if(strcmp(name,p->name)==0)
{ printf("姓名:\t\t住址:\t\t邮编:\t\t电话:\n");
printf("%s\t\t%s\t\t%ld\t\t%s\n",p->name,p->address,p->zip,p->phone);
flag=1;
}
p=p->next;
}
return flag;
}
/* 按姓名删除一条通讯录记录 */
int delete1(add_list **head)
{ add_list *p,*q,*t;
char name[],c;
int flag=0;
printf("请输入要删除人的姓名:");
scanf("%s",name);
q=p=*head;
while(p!=NULL)
{ if(strcmp(name,p->name)==0) /* 找到要删除的人 */
{ printf("姓名:\t\t住址:\t\t邮编:\t\t电话:\n");
printf("%s\t\t%s\t\t%ld\t\t%s\n",p->name,p->address,p->zip,p->phone);
printf("真的要删除吗?(Y:是,N:否)\n"); /* 征求意见(删&不删) */
getchar();c=getchar();
if(c=='y'||c=='Y') /* 删除 */
{ if(p==*head)
*head=p->next;
else
q->next=p->next;
t=p;
p=p->next;
free(t);
flag=1;
}
else /* 不删,跳过 */
{ q=p;
p=p->next;
flag=1;
}
}
else /* 没找到,继续 */
{ q=p;
p=p->next;
}
}
return flag;
printf("按回车键返回......");
getchar();
}
/* 显示菜单并选择菜单项 */
int menu_select()
{ char c;
system("cls");
printf("\t\t
2024-12-23 00:32
2024-12-23 00:25
2024-12-22 23:51
2024-12-22 23:11
2024-12-22 22:33
2024-12-22 22:03