求助啊。。。C++(帮帮忙,分数少了点。。。)

[复制链接]
查看11 | 回复2 | 2010-9-27 11:42:29 | 显示全部楼层 |阅读模式
题目的地址:http://acm.hdu.edu.cn/showproblem.php?pid=1106(大学网站,不会有毒的)
#include
#include
using namespace std;
int a[100],b[100];
int mi(int);
void main()
{
vector a,b;
vector::iterator c=a.begin();
int d,e(0),i(0),j(0);
while (cin>>d&&d=='\n')//输入
{
a.push_back(d);
}
for (;c!=a.end();c++)
{
a=*c;
i++;
if (*c==5)//找到5.
{
for (int d=i+1;d>=0;d--)
{

b[e]=b[e]+a[j]*mi(d);

j++;
}
i=0;
e++;
}

}
int t;
for (int i=0;ib)
{
t=b[i+1];
b[i+1]=b;
b=t;
}
}
for (int i=0;i<e;i++)//输出
{
cout<<b;
}
}
int mi(int x)//乘以10的n次方。
{
int s(1);
for (int i=0;i<x;i++)
{

s=s*10;
}
if (x==0)
{
return 1;
}
return s;
}
程序运行不对。。。

回复

使用道具 举报

千问 | 2010-9-27 11:42:29 | 显示全部楼层
int d,e(0),i(0),j(0);这句都定义i了,为什么main函数中的for语句又重新定义i
回复

使用道具 举报

千问 | 2010-9-27 11:42:29 | 显示全部楼层
就是有问题啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行