两种解法:
1、逐位相加
#include
#include
using namespace std;
int main()
{
int s;
cin>>s;
int sum=0;
while (s!=0)
{
sum=sum+s%10;
s=s/10;
}
cout<<sum;
return 0;
}
2、转换成字符串相加
#includ...
分类:
其他好文 时间:
2015-01-06 10:03:24
阅读次数:
112
输入一段文章,输出最高频与次高频的单词(全部小写,逗号分隔)。文章中仅出现空格,逗号和句号这三种分隔符。
不考虑频率一致的情况。忽略大小写。
输入:I am a student.I come from XiDian,I love XiDian.
输出:i,xidian
#include
#include
#include
#include
using n...
分类:
其他好文 时间:
2015-01-06 00:54:14
阅读次数:
233
/*
你有一个容量为100的箩筐,给你30个物品,每个物品的体积已知,
问:最多能装多少个物品。
思路:排序,最小的体积的先放
输入:5 59 100 1 2 3 20 20 30 40 50 60 20 20 20 20 10 10 10 10 10 100 20 20 20 20 20 20 20 30
输出:11
*/
#include
using namespace...
分类:
其他好文 时间:
2015-01-06 00:53:04
阅读次数:
169
输入一个字符串,判断是否含有相同的子串(字串长度大于1),是输出1,否,输出0。
例如12312含有两个12,所以输出1;23456则没有相同子序列,输出0.
输入:12312
输出:1
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
string s;
cin>...
分类:
其他好文 时间:
2015-01-06 00:51:48
阅读次数:
198
输入一个字符串,去掉重复出现的字符,并把剩余的字符串排序输出。
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
string s;
while(cin>>s)
{
for(int i=0;i<s.size();++i)
for(i...
分类:
编程语言 时间:
2015-01-06 00:51:40
阅读次数:
232
输入两个字符串,找出在第一个字符串中,有多少个第二个子串,输出个数,并输出删除全部第二个子串后的字符串。
输入:abcdcde cd
输出:2 abe
#include
#include
using namespace std;
int delete_sub_str(const char *str,const char *sub_str,char *result)
{
...
分类:
其他好文 时间:
2015-01-06 00:50:31
阅读次数:
140
#include
using namespace std;
int calZeroNum(int num)
{
if (0 == num)
{
return 0;
}
int count = 0;
while (0 != num)
{
if (0 == (num & 1))
{
...
分类:
其他好文 时间:
2015-01-05 16:46:48
阅读次数:
111
#include
using namespace std;
int main()
{
int N = 0;
while(cin>>N)
{
int *students = new int [N + 1];//students[0]保留不用
memset(students, 1, sizeof(int) * (N +1...
分类:
其他好文 时间:
2015-01-05 16:41:34
阅读次数:
115
#include
#include "OJ.h"
using namespace std;
/*
Description
给定一个字符串,将字符串中所有和前面重复多余的字符删除,其余字符保留,输出处理后的字符串。需要保证字符出现的先后顺序。
Prototype
int GetResult(const char *input, char *output)
I...
分类:
其他好文 时间:
2015-01-05 16:40:34
阅读次数:
109
背景:服务器安装windows2008R2系统,发现系统只能使用2T空间,大于2T部分不可用。服务器信息:华为RH2485v2/600G*6验证问题:1、安装linux系统,系统盘会不会只能使用2T空间2、安装windows2008R2系统怎样才能让系统盘能使用超过2T的空间实验环境:一台DELLR710/1T*6,做raid后..