谁帮我看看这几道题怎么用C++语句在DOS下完成?

borland_boy 2003-05-17 11:20:19
一道题给20分,拜托各位兄弟了

9.6 输入一行字母,统计每个字母的个数,同一字母不分大写,小写.用下标为0的元素统计字符"A"和"a"的个数,下标为1的元素统计字符"B"和"b"的个数...

9.11 输入若干有序数放在数组中.然后输入一个数,插入到此有序数列中,插入后,数组中的数仍然有序.请对以下三种情况运行你的程序,以便验证你的程序是否正确.
(1)插在最前 (2)插在最后 (3)插在中间

9.12 在完成9.11题的基础上,插入任意多个数,当输入-1时,结束插入.

9.13 使两个有序数列合并成一个有序数列,合并后的数列仍有序.注意:不得采用重新排序的方法.

9.14 请在数列中选出前两个最大数.

9.15 有52张牌,使它们全部正面朝上.从第2张牌开始,把凡是2的倍数位置上的牌翻成正面朝下;接着从第3张牌开始,把凡是3的倍数位置上的牌,正面朝下的翻成正面朝上,正面朝上的翻成正面朝下;接着从第4张牌开始,把凡是4的倍数位置上的牌,按以上相同的规律翻转;依次类推,直到第一张要翻的牌的位置超过了26为止.统计有几张牌正面朝上,以及它们的位置号.

9.16 编写函数把任意十进制正整数转换成二进制数.提示:把十进制数不断被2除,余数放在一个一维数组中,直到商数为零.在主函数中进行输出,要求不得按逆序输出.

9.17 编写函数把任意十进制浮点数转换成八进制数.要求在主函数中输出结果.
...全文
25 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
borland_boy 2003-05-18
  • 打赏
  • 举报
回复
首先我要感谢 penu(懒猫·达也) 我会给你分的

其次我要声明一件事情:

这些题的答案不是我要的,是一个朋友刚学C++让我帮忙做,我刚好手里有个很急的工作要做这个礼拜都没有空闲的时间所以就劳驾各位代劳了

我如果有时间就自己做了,而且做这类问题也很有好处

如果谁以后没时间做而我有时间我也会帮忙的
888888888888 2003-05-18
  • 打赏
  • 举报
回复
关注
Behard 2003-05-18
  • 打赏
  • 举报
回复
scanf ( "%ld", &value );
Behard 2003-05-18
  • 打赏
  • 举报
回复
靠,写错了 DOS 的 int 是 16 位的
9.16
void main()
{
long value;
int i;
int firstprn = 0;

scanf ( "%d", &value );
if ( value<=0 )
{ printf("The value <= 0!\n"); return; }

printf("The value is:\n");
for ( i=1; i<32; i++ )
{
if( value & (0x80000000>>i) )
firstprn = 1;
if ( firstprn )
printf ( "%d", (value & (0x80000000>>i))>>(31-i) );
}
printf("\n");
}
Behard 2003-05-18
  • 打赏
  • 举报
回复
9.16
int main()
{
int value;
int i;
int firstprn = 0;

scanf ( "%d", &value );
if ( value<=0 )
{ printf("The value <= 0!\n"); return; }

printf("The value is:\n");
for ( i=1; i<32; i++ )
{
if( value & (0x80000000>>i) )
firstprn = 1;
if ( firstprn )
printf ( "%d", (value & (0x80000000>>i))>>(31-i) );
}
printf("\n");
}
penu 2003-05-17
  • 打赏
  • 举报
回复
9.15题:
void checkcard(void)
{
bool card[52];
int i,pos,num;
for(i=0;i<52;i++)
card[i]=true;
pos=0;
while(pos<26)
{
for(i=pos,i<52;i++)
if (i%pos==0)
card[i]=!card[i];
pos++;
}
num=0;
printf("\n");
for(i=0;i<52;i++)
if (card[i])
{
num++;
printf("%d\t",i+1);
}
printf("\ncount : %d",num);
}
penu 2003-05-17
  • 打赏
  • 举报
回复
9.14题:
void getmaxintable(int table[255],int count)
{
int i,no1,no2;
no1=table[0];
for(i=1;i<count;i++)
if (table[i]>no1)
{
no2=no1;
no1=table[i];
}
printf("\nNO.1 is %d",no1);
printf("\nNO.2 is %d",no2);
}
systermman 2003-05-17
  • 打赏
  • 举报
回复
^_^,这个人比我还要懒,不过发现懒猫挺勤快的 ^_^
systermman 2003-05-17
  • 打赏
  • 举报
回复
up
gz
penu 2003-05-17
  • 打赏
  • 举报
回复
9.13题:
int insertnum(int newnum,int numtable[255],int tablenumcount)
{
int i,pos;
if (tablenumcount>=255)
return(255);
numtable[tablenumcount]=65535;
for(i=tablenumcount;i>-1;i--)
if (newnum>numtable[i])
break;
pos=i+1;
for(i=tablenumcount;i>pos;i--)
numtable[i]=numtable[i-1];
numtable[pos]=newnum;
tablenumcount++;
return(tablenumcount);
}
int addnumtable(int objectnumtable[255],int ontcount,int sourcenumtable[255],int sntcount)
{
int i,count;
if (sntcount+ontcount>=255)
return(ontcount);
count=ontcount;
for(i=0;i<sntcount;i++)
count=insertnum(sourcenumtable[i],objectnumtable,count);
return(count);
}
penu 2003-05-17
  • 打赏
  • 举报
回复
9.12题:
int insertnum(int newnum,int numtable[255],int tablenumcount)
{
int i,pos;
if (tablenumcount>=255)
return(255);
numtable[tablenumcount]=65535;
for(i=tablenumcount;i>-1;i--)
if (newnum>numtable[i])
break;
pos=i+1;
for(i=tablenumcount;i>pos;i--)
numtable[i]=numtable[i-1];
numtable[pos]=newnum;
tablenumcount++;
return(tablenumcount);
}
int insertmorenum(int ntable[255],int tcount)
{
int n,count;
count=tcount;
if (count>=255)
return(255);
while(count<255)
{
scanf("%d",&n);
if (n==-1)
break;
count=insertnum(n,ntable,tcount);
}
return(count);
}
penu 2003-05-17
  • 打赏
  • 举报
回复
9.11题:
int insertnum(int newnum,int numtable[255],int tablenumcount)
{
int i,pos;
if (tablenumcount>=255)
return(tablenumcount);
numtable[tablenumcount]=65535;
for(i=tablenumcount;i>-1;i--)
if (newnum>numtable[i])
break;
pos=i+1;
for(i=tablenumcount;i>pos;i--)
numtable[i]=numtable[i-1];
numtable[pos]=newnum;
tablenumcount++;
return(tablenumcount);
}
daoxue1 2003-05-17
  • 打赏
  • 举报
回复
penu(懒猫·达也) :
while((c=str[num])!=NULL)
{
if (c>='A' && c<='Z')
charcount[c-'A']++;
if (c>='a' && c<='z')
charcount[c-'a']++;
num++;
}
Behard 2003-05-17
  • 打赏
  • 举报
回复
这么简单的都要问?
你的四个三角是怎么来的?
daoxue1 2003-05-17
  • 打赏
  • 举报
回复
呵,是不是要交作业了,急来抱佛脚,该打!
penu 2003-05-17
  • 打赏
  • 举报
回复
9.6题:
void countchar(const *str,int charcount[26])
{
int num;
char c;
for(num=0;num<26;num++)
charcount[num]=0;
num=0;
while(str[num]!=NULL)
{
c=str[num++];
if (c>='A' && c<='Z')
charcount[c-'A']++;
if (c>='a' && c<='z')
charcount[c-'a']++;
}
}
penu 2003-05-17
  • 打赏
  • 举报
回复
一时手痒,呵呵。

做得太快没仔细检查,请大家帮忙看看。


好久没做这些题了呀!
penu 2003-05-17
  • 打赏
  • 举报
回复
9.17题:
void main(void)
{
int dn
int bn[255],tbn[255],pos,tmp;
int i;
for(i=0;i<255;i++)
{
bn[i]=0;
tbn[i]=0;
}
scanf("%d",&dn);
pos=0;
tmp=dn;
while(tmp>0)
{
tbn[pos++]=tmp%8;
tmp=tmp/8;
}
for(i=0;i<pos;i++)
bn[i]=tbn[pos-i-1];
printf("\nInput : %d\nOutput : ",dn);
for(i=0;i<pos;i++)
printf("%d",bn[i]);
}
3851391 2003-05-17
  • 打赏
  • 举报
回复
楼主真绝,佩服!
chifengwatch 2003-05-17
  • 打赏
  • 举报
回复
看看
加载更多回复(4)

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧