1.С?小程序c小程序???c????Դ??
2.用C语言写一个小程序!
3.cè¯è¨çä¸ä¸ªå°ç¨åº
4.谁能用C语言帮我写几个小程序 急求
С?语言源码语言源码用云趋势源码???c????Դ??
题目:家庭财务管理小程序
1.程序分析:
2.程序源代码:
/*money management system*/
#include "stdio.h"
#include "dos.h"
main()
{
FILE *fp;
struct date d;
float sum,chm=0.0;
int len,i,j=0;
int c;
char ch[4]="",ch1[]="",chtime[]="",chshop[],chmoney[8];
pp: clrscr();
sum=0.0;
gotoxy(1,1);printf("|---------------------------------------------------------------------------|");
gotoxy(1,2);printf("| money management system(C1.0) . |");
gotoxy(1,3);printf("|---------------------------------------------------------------------------|");
gotoxy(1,4);printf("| -- money records -- | -- today cost list -- |");
gotoxy(1,5);printf("| ------------------------ |-------------------------------------|");
gotoxy(1,6);printf("| date: -------------- | |");
gotoxy(1,7);printf("| | | | |");
gotoxy(1,8);printf("| -------------- | |");
gotoxy(1,9);printf("| thgs: ------------------ | |");
gotoxy(1,);printf("| | | | |");
gotoxy(1,);printf("| ------------------ | |");
gotoxy(1,);printf("| cost: ---------- | |");
gotoxy(1,);printf("| | | | |");
gotoxy(1,);printf("| ---------- | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("|---------------------------------------------------------------------------|");
i=0;
getdate(&d);
sprintf(chtime,"%4d.%d.%d",d.da_year,d.da_mon,d.da_day);
for(;;)
{
gotoxy(3,);printf(" Tab __browse cost list Esc __quit");
gotoxy(,);printf(" ");
gotoxy(,);printf(" ");
gotoxy(,7);printf("%s",chtime);
j=;
ch[0]=getch();
if(ch[0]==)
break;
strcpy(chshop,"");
strcpy(chmoney,"");
if(ch[0]==9)
{
mm:i=0;
fp=fopen("home.dat","r+");
gotoxy(3,);printf(" ");
gotoxy(6,4);printf(" list records ");
gotoxy(1,5);printf("|-------------------------------------|");
gotoxy(,4);printf(" ");
gotoxy(,5);printf(" |");
while(fscanf(fp,"%s%s%f\n",chtime,chshop,&chm)!=EOF)
{ if(i==)
{ getch();
i=0;}
if ((i%)<)
{ gotoxy(4,6+i);
printf(" ");
gotoxy(4,6+i);}
else
if((i%)>)
{ gotoxy(,4+i-);
printf(" ");
gotoxy(,4+i-);}
i++;
sum=sum+chm;
printf("%s %-s %6.1f\n",chtime,chshop,chm);}
gotoxy(1,);printf("|---------------------------------------------------------------------------|");
gotoxy(1,);printf("| |");
gotoxy(1,);printf("|---------------------------------------------------------------------------|");
gotoxy(,);printf("total is %8.1f$",sum);
fclose(fp);
gotoxy(,);printf("press any key to.....");getch();goto pp;
}
else
{
while(ch[0]!='\r')
{ if(j<)
{ strncat(chtime,ch,1);
j++;}
if(ch[0]==8)
{
len=strlen(chtime)-1;
if(j>)
{ len=len+1; j=;}
strcpy(ch1,"");
j=j-2;
strncat(ch1,chtime,len);
strcpy(chtime,"");
strncat(chtime,ch1,len-1);
gotoxy(,7);printf(" ");}
gotoxy(,7);printf("%s",chtime);ch[0]=getch();
if(ch[0]==9)
goto mm;
if(ch[0]==)
exit(1);
}
gotoxy(3,);printf(" ");
gotoxy(,);
j=0;
ch[0]=getch();
while(ch[0]!='\r')
{ if (j<)
{ strncat(chshop,ch,1);
j++;}
if(ch[0]==8)
{ len=strlen(chshop)-1;
strcpy(ch1,"");
j=j-2;
strncat(ch1,chshop,len);
strcpy(chshop,"");
strncat(chshop,ch1,len-1);
gotoxy(,);printf(" ");}
gotoxy(,);printf("%s",chshop);ch[0]=getch();}
gotoxy(,);
j=0;
ch[0]=getch();
while(ch[0]!='\r')
{ if (j<6)
{ strncat(chmoney,ch,1);
j++;}
if(ch[0]==8)
{ len=strlen(chmoney)-1;
strcpy(ch1,"");
j=j-2;
strncat(ch1,chmoney,len);
strcpy(chmoney,"");
strncat(chmoney,ch1,len-1);
gotoxy(,);printf(" ");}
gotoxy(,);printf("%s",chmoney);ch[0]=getch();}
if((strlen(chshop)==0)||(strlen(chmoney)==0))
continue;
if((fp=fopen("home.dat","a+"))!=NULL);
fprintf(fp,"%s%s%6s",chtime,chshop,chmoney);
fputc('\n',fp);
fclose(fp);
i++;
gotoxy(,5+i);
printf("%s %-s %-6s",chtime,chshop,chmoney);
}}}
用C语言写一个小程序!
/*money management system*/
#include "stdio.h"
#include "dos.h"
#include "conio.h"
main()
{
FILE *fp;
struct date d;
float sum,小程序c小程序论坛下载源码网源码下载chm=0.0;
int len,i,j=0;
int c;
char ch[4]="",ch1[]="",chtime[]="",chshop[],chmoney[8];
pp:
clrscr();
sum=0.0;
gotoxy(1,1);printf("|---------------------------------------------------------------------------|");
gotoxy(1,2);printf("| money management system(C1.0) . |");
gotoxy(1,3);printf("|---------------------------------------------------------------------------|");
gotoxy(1,4);printf("| -- money records -- | -- today cost list -- |");
gotoxy(1,5);printf("| ------------------------ |-------------------------------------|");
gotoxy(1,6);printf("| date: -------------- | |");
gotoxy(1,7);printf("| | | | |");
gotoxy(1,8);printf("| -------------- | |");
gotoxy(1,9);printf("| thgs: ------------------ | |");
gotoxy(1,);printf("| | | | |");
gotoxy(1,);printf("| ------------------ | |");
gotoxy(1,);printf("| cost: ---------- | |");
gotoxy(1,);printf("| | | | |");
gotoxy(1,);printf("| ---------- | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("| | |");
gotoxy(1,);printf("|---------------------------------------------------------------------------|");
i=0;
getdate(&d);
sprintf(chtime,"%4d.%d.%d",d.da_year,d.da_mon,d.da_day);
for(;;)
{
gotoxy(3,);printf(" Tab __browse cost list Esc __quit");
gotoxy(,);printf(" ");
gotoxy(,);printf(" ");
gotoxy(,7);printf("%s",chtime);
j=;
ch[0]=getch();
if(ch[0]==)
break;
strcpy(chshop,"");
strcpy(chmoney,"");
if(ch[0]==9)
{
mm:
i=0;
fp=fopen("home.dat","r+");
gotoxy(3,);printf(" ");
gotoxy(6,4);printf(" list records ");
gotoxy(1,5);printf("|-------------------------------------|");
gotoxy(,4);printf(" ");
gotoxy(,5);printf(" |");
while(fscanf(fp,"%s%s%f\n",chtime,chshop,&chm)!=EOF)
{
if(i==)
{
getch();
i=0;
}
if((i%)<)
{
gotoxy(4,6+i);
printf(" ");
gotoxy(4,6+i);
}
else
if((i%)>)
{
gotoxy(,4+i-);
printf(" ");
gotoxy(,4+i-);
}
i++;
sum=sum+chm;
printf("%s %-s %6.1f\n",chtime,chshop,chm);
}
gotoxy(1,);printf("|---------------------------------------------------------------------------|");
gotoxy(1,);printf("| |");
gotoxy(1,);printf("|---------------------------------------------------------------------------|");
gotoxy(,);printf("total is %8.1f$",sum);
fclose(fp);
gotoxy(,);printf("press any key to.....");getch();goto pp;
}
else
{
while(ch[0]!='\r')
{
if(j<)
{
strncat(chtime,ch,1);
j++;
}
if(ch[0]==8)
{
len=strlen(chtime)-1;
if(j>)
{ len=len+1; j=;}
strcpy(ch1,"");
j=j-2;
strncat(ch1,chtime,len);
strcpy(chtime,"");
strncat(chtime,ch1,len-1);
gotoxy(,7);printf(" ");
}
gotoxy(,7);printf("%s",chtime);ch[0]=getch();
if(ch[0]==9)
goto mm;
if(ch[0]==)
exit(1);
}
gotoxy(3,);printf(" ");
gotoxy(,);
j=0;
ch[0]=getch();
while(ch[0]!='\r')
{
if (j<)
{
strncat(chshop,ch,1);
j++;
}
if(ch[0]==8)
{
len=strlen(chshop)-1;
strcpy(ch1,"");
j=j-2;
strncat(ch1,chshop,len);
strcpy(chshop,"");
strncat(chshop,ch1,len-1);
gotoxy(,);printf(" ");
}
gotoxy(,);printf("%s",chshop);ch[0]=getch();
}
gotoxy(,);
j=0;
ch[0]=getch();
while(ch[0]!='\r')
{
if (j<6)
{
strncat(chmoney,ch,1);
j++;
}
if(ch[0]==8)
{
len=strlen(chmoney)-1;
strcpy(ch1,"");
j=j-2;
strncat(ch1,chmoney,len);
strcpy(chmoney,"");
strncat(chmoney,ch1,len-1);
gotoxy(,);printf(" ");
}
gotoxy(,);printf("%s",chmoney);ch[0]=getch();
}
if((strlen(chshop)==0)||(strlen(chmoney)==0))
continue;
if((fp=fopen("home.dat","a+"))!=NULL);
fprintf(fp,"%s%s%6s",chtime,chshop,chmoney);
fputc('\n',fp);
fclose(fp);
i++;
gotoxy(,5+i);
printf("%s %-s %-6s",chtime,chshop,chmoney);
}
}
getch();
}
cè¯è¨çä¸ä¸ªå°ç¨åº
#include "stdio.h"#include <math.h>
#define N
int main()
{
int a[N];
int i, j;
//å°2å°N-1é´çæ°æ¾å¨çåä¸
i = 2;
while(i<N)
{
a[i]=1;
i++;
}
i = 2;
int limit;
limit = (int)sqrt((double)(N-1));//计ç®é¤æ°çä¸élimit
while(i<limit)
{
//ç¨içå»çåä¸içåæ°çæ°ï¼ä¸å æ¬iæ¬èº«
j = 2*i;
while(j<N)
{
a[j] = 0;
j += i;
}
//æ¾å°çåä¸ä¸ä¸ªæ°j
j = i+1;
while(a[j]==0&&j<=limit)
j++;
i = j;
}
//å°çåä¸çæ°æå°åºæ¥
i = 2;
int times=0;
while(i<N)
{
if(a[i])
{
printf("%5d", i);
times++;
if((times)%==0)
printf("\n");
}
i++;
}
printf("\n");
return 0;
}
å·²ç»è°è¯,æå,请çå¾
谁能用C语言帮我写几个小程序 急求
1、
#include<stdio.h>
int main()
{
int max(int x,语言源码语言源码用编译过得源码怎样变成源码int y,int z);
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c); //scanf%d间不能有逗号,后面是输入的地址因此得加&
d=max(a,b,c); //输入的是abc,不是x,y,z//x,y,z是形参a,b,c是实参
printf("max=%d",d);//不是print是printf
return 0;
}
int max(int x,int y,int z)
{
return(x>y?(x>z?x:z):(y>z?y:z));
}
2、
#include<stdio.h>
int main()
{
int a,小程序c小程序鼎峰互动网站源码源码b,num1,num2,temp;
printf("Input a & b:");
scanf("%d%d",&num1,&num2);
if(num1>num2) /*找出两个数中的较大值*/
{
temp=num1; num1=num2; num2=temp; /*交换两个整数*/
}
a=num1; b=num2;
while(b!=0) /*采用辗转相除法求最大公约数*/
{
temp=a%b;
a=b;
b=temp;
}
printf("The GCD of %d and %d is: %d\n",num1,num2,a); /*输出最大公约数*/
printf("The LCM of them is: %d\n",num1*num2/a); /*输出最小公倍数*/
return 0;
}
3、
#include <stdio.h>
int main()
{
int year,语言源码语言源码用交付源码指php项目源码result=0;
printf("输入一个年份:\n");
scanf("%d",&year);
if(year%==0)
{
if(year%==0)
result=1;
}
else if(year%4==0)
result=1;
if(result==1)
printf("\n%d是闰年",year);
else
printf("\n%d不是闰年",year);
return 0;
}
4、
#include<stdio.h>
#include<conio.h>
int main()
{
char *toDaXie(char *s);/*函数--变大写*/
char *s;
printf("Input a string please!\n");
gets(s);
printf("The小程序c小程序 result:\n%s\n",toDaXie(s));
getch();
return 0;
}
char *toDaXie(char *s)/*函数--变大写的具体内容*/
{
int i;
for(i=0;i<strlen(s);i++)
{
if(s[i]>&&s[i]<)/*如果这个字是小写字母*/
s[i]-=;/*那就把它变成大写*/
}
return s;
}
5、
#include<stdio.h>
int main()
{
printf("
?语言源码语言源码用
?
?
?
?
");
return 0;
}