') b[i]=a[i];是把a的内容向b拷贝,但是到执行b[i]"og:type" content="webpage">') b[i]=a[i];是把a的内容向b拷贝,但是到执行b[i]" /> ') b[i]=a[i];是把a的内容向b拷贝,但是到执行b[i]"> 大一C语言程序_CMS教程_内存溢出

阅读 7

大一C语言程序,第1张

输出是LBLMNP,所以D正确,选D。

执行完strcat(a,b);后,a的内容是ABLMNP,b的内容仍为LMNP。

while(a[i++]!= '\0') b[i]=a[i];是把a的内容向b拷贝,但是到执行b[i]=a[i];时whiler ()中的a[i++]!= '\0'中i++已经生效了,所以从a[1]开始拷贝到b[1],所以只把a中的BLMNP依次向b[1]开始的元素拷贝。那么,b[1]及以后的内容就是BLMNP了,但b[0]的内容仍然是原来的L。所以b的最后内容就是LBLMNP。

puts输出b内容LBLMNP后还要自动加一个回车。

#include

<stdioh>

void

main()

{int

a[10],b[11],i,j,t,k;printf("请输入

10个数字:\n");

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

scanf("%d",&a[i]);

printf("对他们从小到大排列有:\n");

for(j=0;j<9;j++)

for(i=0;i<9-j;i++)

if(a[i]>a[i+1])

{t=a[i];a[i]=a[i+1];a[i+1]=t;}

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

printf("%d",a[i]);

printf("请输入一个需要插入的数:\n");

scanf("%d",&k);

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

b[i]=a[i];b[10]=k;

printf("对他们从小到大排列有:\n");

for(j=0;j<10;j++)

for(i=0;i<10-j;i++)

if(b[i]>b[i+1])

{t=b[i];b[i]=b[i+1];b[i+1]=t;}

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

printf("%d",b[i]);}

期末的作业吧?呵呵 给你两个:

一、题目:家庭财务管理小程序

2程序源代码:

/money management system/

#include "stdioh"

#include "dosh"

main()

{

FILE fp;

struct date d;

float sum,chm=00;

int len,i,j=0;

int c;

char ch[4]="",ch1[16]="",chtime[12]="",chshop[16],chmoney[8];

pp: clrscr();

sum=00;

gotoxy(1,1);printf("|----------------------------------------------------|");

gotoxy(1,2);printf("| money management system(C10) 200003 |");

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,10);printf("| | | | |");

gotoxy(1,11);printf("| ------------------ | |");

gotoxy(1,12);printf("| cost: ---------- | |");

gotoxy(1,13);printf("| | | | |");

gotoxy(1,14);printf("| ---------- | |");

gotoxy(1,15);printf("| | |");

gotoxy(1,16);printf("| | |");

gotoxy(1,17);printf("| | |");

gotoxy(1,18);printf("| | |");

gotoxy(1,19);printf("| | |");

gotoxy(1,20);printf("| | |");

gotoxy(1,21);printf("| | |");

gotoxy(1,22);printf("| | |");

gotoxy(1,23);printf("|--------------------------------------------------|");

i=0;

getdate(&d);

sprintf(chtime,"%4d%02d%02d",dda_year,dda_mon,dda_day);

for(;;)

{

gotoxy(3,24);printf(" Tab __browse cost list Esc __quit");

gotoxy(13,10);printf(" ");

gotoxy(13,13);printf(" ");

gotoxy(13,7);printf("%s",chtime);

j=18;

ch[0 ]=getch();

if(ch[0]==27)

break;

strcpy (chshop,"");

strcpy(chmoney,"");

if(ch[0]==9)

{

mm:i=0;

fp=fopen("homedat","r+");

gotoxy(3,24);printf(" ");

gotoxy(6,4);printf(" list records ");

gotoxy(1,5);printf("|-------------------------------------|");

gotoxy(41,4);printf(" ");

gotoxy(41,5);printf(" |");

while(fscanf(fp,"%10s%14s%f\n",chtime,chshop,&chm)!=EOF)

{

if(i==36)

{

getch();

i=0;

}

if ((i%36)<17)

{

gotoxy(4,6+i);

printf(" ");

gotoxy(4,6+i);

}

else

if((i%36)>16)

{

gotoxy(41,4+i-17);

printf(" ");

gotoxy(42,4+i-17);

}

i++;

sum=sum+chm;

printf("%10s %-14s %61f\n",chtime,chshop,chm);}

gotoxy(1,23);printf("|----------------------------------------------|");

gotoxy(1,24);printf("| |");

gotoxy(1,25);printf("|----------------------------------------------|");

gotoxy(10,24);printf("total is %81f$",sum);

fclose(fp);

gotoxy(49,24);printf("press any key to");getch();goto pp;

}

else

{

while(ch[0]!='\r')

{

if(j<10)

{

strncat(chtime,ch,1);

j++;

}

if(ch[0]==8)

{

len=strlen(chtime)-1;

if(j>15)

{

len=len+1;

j=11;

}

strcpy(ch1,"");

j=j-2;

strncat(ch1,chtime,len);

strcpy(chtime,"");

strncat(chtime,ch1,len-1);

gotoxy(13,7);printf(" ");

}

gotoxy(13,7);printf("%s",chtime);ch[0]=getch();

if(ch[0]==9)

goto mm;

if(ch[0]==27)

exit(1);

}

gotoxy(3,24);printf(" ");

gotoxy(13,10);

j=0;

ch[0]=getch();

while(ch[0]!='\r')

{

if (j<14)

{

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(13,10);printf(" ");

}

gotoxy(13,10);printf("%s",chshop);ch[0]=getch();}

gotoxy(13,13);

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(13,13);printf(" ");

}

gotoxy(13,13);printf("%s",chmoney);ch[0]=getch();

}

if((strlen(chshop)==0)||(strlen(chmoney)==0))

continue;

if((fp=fopen("homedat","a+"))!=NULL);

fprintf(fp,"%10s%14s%6s",chtime,chshop,chmoney);

fputc('\n',fp);

fclose(fp);

i++;

gotoxy(41,5+i);

printf("%10s %-14s %-6s",chtime,chshop,chmoney);

}

}

}

二、万年历

#include"iostreamh"

#include"iomaniph"

#include"stdlibh"leapyear(int a)/是否是闰年

/

{

if((a%4==0&&a%100!=0)||(a%100==0&&a%400==0))

return (1);

else return (0);

}

int aa[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int cc[12]={31,29,31,30,31,30,31,31,30,31,30,31};char bb[8][8]={"星期

日","星期一","星期二","星期三","星期四","星期五","星期六"};

ww(int a,int b,int c)

{

int n=0,m=0,i,j,k=0;

for(i=1;i<c;i++)

{

if(leapyear(i)==1)

m=m+366;

else m=m+365;

}

for(j=1;j<b;j++)

{if(leapyear(c)==1) k=k+cc[j-1];

else k=k+aa[j-1];

}

n=(m+k+a)%7;

return n;

}

void yuefen(int m)

{

cout<<"最大天数是:";

if(m==2)

cout<<aa[m-1]+1;

else cout<<aa[m-1]<<endl;

}

void nianfen(int n)/打印年份的日历/

{

int i,j,k;

if(leapyear(n)==1)

{

for(j=1;j<=12;j++)

{

cout<<j;

cout<<"月份"<<endl;

cout<<" 日"<<" 一"<<" 二"<<" 三"<<" 四"<<" 五"<<" 六"<<endl;

for(i=0;i<ww(1,j,n);i++)

{

cout<<setw(4)<<"";

}

for(k=1;k<=cc[j-1];k++)

{

cout<<setw(4)<<k;

if((ww(1,j,n)+k)%7==0)

cout<<endl;

}

cout<<endl;

}

}

else

{

for(j=1;j<=12;j++)

{

cout<<j;

cout<<"月份"<<endl;

cout<<ww(1,j,n)<<endl;

cout<<endl<<" 日"<<" 一"<<" 二"<<" 三"<<" 四"<<" 五"<<" 六"<<endl;

for(i=0;i<ww(1,j,n);i++)

{

cout<<setw(4)<<"";

}

for(k=1;k<=aa[j-1];k++)

{

cout<<setw(4)<<k;

if((ww(1,j,n)+k)%7==0)

cout<<endl;

}

cout<<endl;

}

}

}

void nianyue(int n,int y)/打印某年某月的月历/

{

int i,k;

if(leapyear(n)==1)

{

cout<<" 日"<<" 一"<<" 二"<<" 三"<<" 四"<<" 五"<<" 六"<<endl;

for(i=0;i<ww(1,y,n);i++)

{

cout<<setw(4)<<"";

}

for(k=1;k<=cc[y-1];k++)

{

cout<<setw(4)<<k;

if((ww(1,y,n)+k)%7==0)

cout<<endl;

}

cout<<endl;

}

else

{ cout<<endl<<" 日"<<" 一"<<" 二"<<" 三"<<" 四"<<" 五"<<" 六"<<endl;

for(i=0;i<ww(1,y,n);i++)

{

cout<<setw(4)<<"";

}

for(k=1;k<=aa[y-1];k++)

{

cout<<setw(4)<<k;

if((ww(1,y,n)+k)%7==0)

cout<<endl;

}

cout<<endl;

}

}

void main()

{

int n,m;

int day,month ,year;

while(1)

{

cout<<":"<<endl;

cout<<"1查询某年某月某日是星期几"<<endl

<<"2是否为闰年"<<endl

<<"3查询某月的最大天数"<<endl

<<"4打印某年的全年日历"<<endl

<<"5打印某年某月的月历"<<endl

<<"6exit"<<endl

<<":"<<endl;

cout<<"请输入要 *** 作的指令:"<<endl;

cin>>n;

switch(n)

{

case 1:cout<<"请输入要查询的日期:";

cout<<"year:";

cin>>year;

cout<<endl<<"month:";

cin>>month;

cout<<endl<<"day:";

cin>>day;

cout<<"星期是:";

cout<<bb[ww(day,month,year)]<<endl;break;

switch(ww(day,month,year))

{

case 1:cout<<"星期一";break;

case 2:cout<<"星期二";break;

case 3:cout<<"星期三";break;

case 4:cout<<"星期四";break;

case 5:cout<<"星期五";break;

case 6:cout<<"星期六";break;

case 7:cout<<"星期日";break;

}

cout<<endl;break;

case 2:cout<<"请输入要查询的年份:";

cin>>m;

if(leapyear(m)==1) cout<<"是闰年"<<endl;

else cout<<"不是闰年,请返回重新输入"<<endl;

break;

case 3:cout<<"请输入月份:";

cin>>m;

yuefen(m);break;

case 4:cout<<"请输入所要打印年份:";

cin>>m;

nianfen(m);break;

case 5:cout<<"请输入年份:";

cin>>n;

cout<<endl<<"请输入月份:";

cin>>m;

cout<<endl;

nianyue(n,m);break;

case 6:exit(0);

}

}

}

以上就是关于大一C语言程序全部的内容,包括:大一C语言程序、C语言编程,要完整可运行的程序、求C语言200行以上的程序2个等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:

内存溢出

原文地址:

http://outofmemory.cn/zz/9363098.html
程序
(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
acdsee下载 acdsee下载 一级用户组
我的苹果应用程序都显示等待中还删除不了怎么办
上一篇
2023-04-27
祭祖仪式程序
2023-04-27

发表评论
请登录后评论... 登录
提交

    评论列表(0条)
保存
{label} {label}