C语言程序谁帮编一下吧!
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">一、</FONT>数组</STRONG></FONT></P><P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">1、 </FONT>先对包含了若干元素(元素值由键盘输入)的<FONT face="Times New Roman">a</FONT>、<FONT face="Times New Roman">b</FONT>两个一维数组分别进行升序排序,再将它们合并到<FONT face="Times New Roman">c</FONT>数组中,要求合并到<FONT face="Times New Roman">c</FONT>数组中元素仍按升序排列。(每一功能用一函数实现)。</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">2、 </FONT>先对包含了若干元素(元素值由键盘输入)的一维数组<FONT face="Times New Roman">a</FONT>进行升序排序<FONT face="Times New Roman">,</FONT>再删除数组中多余的值相同元素。(每一功能用一函数实现)。</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">二、</FONT>链表(每一功能用一函数实现)</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">1、 </FONT>建立<FONT face="Times New Roman">n</FONT>个结点(结点数据域的值由键盘输入)构成的单链表。</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">2、 </FONT>查找数据域值为<FONT face="Times New Roman">x</FONT>的结点,若找到,返回该结点的地址。</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">1、 </FONT>在数据域值为<FONT face="Times New Roman">x</FONT>的结点之前插入一数据域值为<FONT face="Times New Roman">y</FONT>的结点,若表中无数据域值为<FONT face="Times New Roman">x</FONT>的结点,则将数据域值为<FONT face="Times New Roman">y</FONT>的结点插入表尾。</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman">2、 </FONT>删除数据域值为<FONT face="Times New Roman">x</FONT>的结点,并返回成功与否的标志。</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG><FONT face="Times New Roman"> </FONT>三、木桩问题<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>某农场有一个按编号次序排列的n根木桩构成的首位不相连接的围栏。现欲在这个围栏中选取一些木桩,按照原有的编号次序排列之后这些木桩的高度成为一个升序序列。所谓升序序列就是序列中的任何一个数都不小于它之前的任何一个数。试编写程序从这个围栏中选取合适的木桩使得选出的木桩个数t最大,并求出选取出t根木桩的方案的种数c。<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>例如:围栏由高度分别为10,1,9,8,7,6,3,4,6的木桩构成,则选出高度为1,3,4,6的木桩是满足题意的选取方案。<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>输入:文件中的第一行只有一个数m,表明随后有m个问题的描述信息,每个问题的描述信息格式为n h1 h2 h3····hn。(其中hi(i=1,2,····n)表示第i根木桩的高度)。<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>输出:依次输出每个问题中t和c的解。每行输出一个问题的解。<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 示例:<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 输入<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 3</STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 9 10 1 9 8 7 6 3 4 6<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 3 100 70 102<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 6 40 37 23 89 91 12<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG> 输出<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>4 1<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>2 2<o:p></o:p></STRONG></FONT></P>
<P ><FONT color=#1111ee><STRONG>3 3<BR>上述题目谁会做啊?帮帮忙吧!急死啦![em08][em06]</STRONG></FONT></P>
跟我的一样啊
哎,怎么跟我的 完全一摸一样啊,只可惜没回答啊!! LS 怎么把这么老的帖子也给挖出来,PF~PF~ 1年了都无人问津[tk01]第2个题
#include<stdio.h>void main()
{
//定义变量
int array[];
int i;
int j;
//输入并访问
printf("请输入数组的元素:");
for(i=0;i<array.length;i++)
{
scanf("%d\n",array[i]);
}
//比较
for(i=0;i<array.length;i++)
{
for(j=0;j<array.length-i-1;j++)
{
if(array[j]>array[j+1])
{
temp=array[j+1];
array[j+1]=array[j];
array[j]=temp;
}
}
}
//输出结果
for(i=0;i<array.length;i++)
{
if(array[i]==array[i]){
continue;
printf("%d\n",array[i]);
}
}
}
闷的心慌
做个第一题 程序若有不当之处 还请诸位斧正!main()
{
int i,j,k,p,q,temp;
int a[10],b[10],c[20];
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
scanf("%d",&b[i]);
}
for(i=0;i<10;i++)
{
for(j=i;j<i-1,k<i-1;j++,k++)
{
if(a[i]>a[j]) p=j;
if(b[i]>b[k]) q=k;
temp=a[p];a[p]=a[i];a[p]=temp;
temp=b[q];b[q]=a[i];a[q]=temp;
}
}
while(i<10&&j<10)
{
if(a[i]<b[j])
c[k++]=a[i++];
else
c[k++]=b[j++];
}
whlie(i<10) c[k++]=a[i++];
while(j<10) c[k++]=b[j++];
for(k=0;k<20;k++)
{
prinf("%d",&c[k]);
}
}
[[it] 本帖最后由 liyanhong 于 2008-6-29 16:39 编辑 [/it]]
回复 6# liyanhong 的帖子
提个建议啊 题目说好了是每个功能用函数完成的下面是对程序的建议
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
scanf("%d",&b[i]);
}
for(i=0;i<10;i++)
{
for(j=i;j<i-1,k<i-1;j++,k++)
{
if(a[i]>a[j]) p=j;
if(b[i]>b[k]) q=k;
temp=a[p];a[p]=a[i];a[p]=temp;
temp=b[q];b[q]=a[i];a[q]=temp;
}
}
这两个功能 一个是输入 一个是排序 可以分开写吧
用一函数完成输入
一个函数完成排序 这样会好些吧
while(i<10&&j<10)
{
if(a[i]<b[j])
a[++]=c[k++];
else
b[j++]=c[k++];
}
whlie(i<10) a[i++]=c[k++];
while(j<10) b[j++]=c[k++];
for(k=0;k<20;k++)
{
prinf("%d",&c[k]);
}
还有这段 先不说对不对 好像最后都没给c[]这个数组赋值
所以输出也不会有结果吧
我写反了
谢谢楼上 小程序不喜欢用函数条件比较简陋 写上去就没运行了[em01]
[[it] 本帖最后由 liyanhong 于 2008-6-29 16:42 编辑 [/it]] 呵呵,我现才开始! C/C++ code
void input_memo() /* 输入信息,公共接口。 */
{
struct memo m;
clrscr();
fflush(stdin);
printf(" Memname: ");
gets(m.name);
printf(" Memtime: ");
gets(m.event_date);
printf(" Memtext: ");
gets(m.context);
printf(" Memremindtime: ");
gets(m.remind_date);
insert_memo(&m);
}
void insert_memo(struct memo *m) /* 私有接口,用于访问文件,输入信息。 */
{
FILE *fp;
fp=fopen("memo.dat","at+")
fwrite(m,sizeof(struct memo), 1, fp);
fclose(fp);
}
int makename() /* 通过名字查询 */
{
int flag=1;
FILE *fp;
struct memo qq;
char a[50];
clrscr();
if((fp=fopen("memo.dat","rt"))==NULL)
{
printf("No anydate!");
return 0;
}
printf("Please input memname: ");
fflush(stdin);
scanf("%s",a);
printf("\n");
do{
fread(&qq,sizeof(struct memo),1,fp);
if(strnicmp(a,qq.name)==0) //比较一致即输出
{
printf("\nName: %s\nTime: %s\nText: %s\nRemind: %s\n\n",qq.name,qq.event_date,qq.context,qq.remind_date);
flag=0;
}
}while(feof(fp)==0) ;
if(flag!=0)
{
printf("No matching date!!\n");
printf("\n");
}
printf("\nInput anykey back!\n");
getch();
fclose(fp);
return 1;
}
相关连接C/C++ http://bbs.palmjob.net/technology/1005/080623225851518-1.htm
C/C++ 论坛 http://bbs.palmjob.net/
页:
[1]
