我都发了三个帖子了,没人写出来,要是谁写出来,三个帖子的分都给他!

kaihongmail 2009-05-03 07:50:03
输入一个数,

比如234343,(有1个2,2个4,3个3)每个位上的数 乘以它在数中的个数:2* 1 ,3* 3 ,4* 2 3* 3 4* 2 3* 3 然后把它们相加得n ,然后求n/11 。如果有余数输出FALSE 如果没有余数,输出OK。

麻烦大家帮个忙。在线等。
...全文
73 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiao0915 2009-05-03
  • 打赏
  • 举报
回复
个人觉得二楼的代码也很不错
怎么没人用vector
kaihongmail 2009-05-03
  • 打赏
  • 举报
回复
啊!我写的这会 大家发了这么多啊 一楼对我刚想结贴 不过2楼干吗发c程序 我要的是c++。。。不好意思 谢谢大家了
kaihongmail 2009-05-03
  • 打赏
  • 举报
回复
好 哥们 你也去其它两个帖子留下言吧 我不想把分浪费了。。。
http://topic.csdn.net/u/20090503/19/d3fa0744-7893-438f-9ee2-68b3149866f1.html
http://topic.csdn.net/u/20090503/18/f2989212-ce06-4fcf-a956-2bb3f3889c15.html
Paradin 2009-05-03
  • 打赏
  • 举报
回复
1楼应该才是lz意思
wuyu637 2009-05-03
  • 打赏
  • 举报
回复
#include <iostream>
#include <stdlib.h>
#include <string.h>



int main(){




cout << "input the number "<< endl;

long number;
cin >> number;

int recorder[11]={0};

long temp = number;
while(temp !=0)
{
int a= temp % 10;
cout << a << endl;
recorder[a]++;
temp =temp/10;
}
int sum = 0;
for(int i = 1;i<10;i++)
{
sum = sum +i*recorder[i]*recorder[i];
}

cout << "the sum is " << sum << endl;


if(sum%11==0)
{
cout << "ok" << endl;
}
else
{
cout << sum%11 << endl;
}

}
liao05050075 2009-05-03
  • 打赏
  • 举报
回复

#include<iostream>
#include<cstring>
using namespace std;

int main()
{
char s[100];
int num[10]={0};
int n=0;
gets(s);
int len=strlen(s);
int i;
for(i=0;i<len;i++)
num[s[i]-'0']++;
for(i=1;i<10;i++)
n+=num[i]*i;
if(n%11) puts("FALSE");
else puts("OK");
return 0;
}
Paradin 2009-05-03
  • 打赏
  • 举报
回复

#include <iostream>
using namespace std;


int main()
{
int digit_cnt[10];
long num, tmp, n;

for (int i = 0; i < 10; ++i)
digit_cnt[i] = 0;

cin >> num;
tmp = num;
while (num)
{
++digit_cnt[num % 10];
num = num / 10;
}

n = 0;
while (tmp)
{
n += (tmp % 10) * digit_cnt[tmp % 10];
tmp = tmp / 10;
}


cout << "n = " << n << endl;
cout << "n/11 =" << n/11 << endl;
cout << (n %11 ? "FALSE" : "OK") << endl;
}


测了

64,671

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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