uva 10929 - You can say 11
#include <cstdio>
using namespace std; char in[]; int main()
{
while(gets(in))
{
if(in[] == '' && in[] == ) break; int s = ;
for (int i = ; in[i] != ; i++)
{
s += (in[i] - '');
s *= ;
s %= ;
}
printf(s == ? "%s is a multiple of 11.\n" : "%s is not a multiple of 11.\n", in);
}
return ;
}
第二种思路不错,多想想!
#include<iostream>
#include<string> using namespace std; int main(){
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout); char num[]; int sum; while(){
cin>>num; if(num[]=='' && strlen(num)==) break; sum=; for(int i=;i<strlen(num);i+=) sum+=num[i]-'';
for(int i=;i<strlen(num);i+=) sum-=num[i]-'';
cout << "sum: " << sum << endl;
if(sum%==) cout<<num<<" is a multiple of 11."<<endl;
else cout<<num<<" is not a multiple of 11."<<endl;
}
}
uva 10929 - You can say 11的更多相关文章
- uva10001 Garden of Eden
Cellular automata are mathematical idealizations of physical systems in which both space and time ar ...
- uva10344 23 out of 5
Your task is to write a program that can decide whether you can nd an arithmetic expression consisti ...
- uva11025 The broken pedometer
6741870 ksq2013 UVA 11205 Accepted 60 C++11 5.3.0 1002 2016-08-04 14:25:22 题目大意如下:给定n个LED灯串,每个灯串由p ...
- uva10167 Birthday Cake
Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them. Now we put t ...
- 地区sql
/*Navicat MySQL Data Transfer Source Server : localhostSource Server Version : 50136Source Host : lo ...
- #11 UVA 10529 Dumb Bones
题意: 放一堆排,每放一张,有pa的概率让左边的全倒,有pb的概率让右边全倒 问在最优策略下,最少要放几张才能摆放出n张 1<=n<=1000 题解: 这题应该还是很经典的 首先是期望部分 ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA - 1025 A Spy in the Metro[DP DAG]
UVA - 1025 A Spy in the Metro Secret agent Maria was sent to Algorithms City to carry out an especia ...
随机推荐
- PHP中检测ajax请求的代码例子
多数情况下,基于JavaScript 的Js框架如jquery.Mootools.Prototype等,在发出Ajax请求指令时,都会发送额外的 HTTP_X_REQUESTED_WITH 头部信息, ...
- Hibernate数据库对象的创建与导出
Hibernate 与数据库的关系是ORM关系,对象映射数据库. 那么如何通过对象对数据库进行各种对象的ddl与dml操作呢? 数据库对象操作的〈database-object /〉+ SchemaE ...
- 机器学习之python: kNN
################################################## # kNN : k Nearest Neighbour # Author : Monne # Da ...
- java eclipse 连接数据库全过程
1.需要下载一个jar包.地址 http://pan.baidu.com/s/1i50LRId 2.代码如下: import java.sql.*; public class Mytest { pub ...
- Android Recovery的汉化 显示中文
Android Recovery的汉化 显示中文,有需要的朋友可以参考下. 首先下载开源的recovery源码,地址为https://github.com/xiaolu/android_bootabl ...
- QML控件类关系图
花了点时间整理了下QML控件之间的关系图和QML控件和C++类的对应关系,基于Qt5.6版本 其他版本可能会有差异 图片像素比较大,另存为后放大图片就可以看清楚了 工程下载地址 QMLClassDia ...
- zabbix 插件使用问题
[elk@dr-mysql01 frontend]$ ../../bin/logstash -f std02.conf Settings: Default pipeline workers: 8 Pi ...
- 2016.08.13/2/index/_d_Lucene54_0.dvm: Too many open files
er[file_system_exception: /elk/elasticsearch/data/es_cluster/nodes/0/indices/logstash-zjzc-frontend- ...
- ASP.NET MVC framework 学习
http://www.cnblogs.com/lmfeng/archive/2013/03/28/2986123.html MVC数据绑定方式 http://www.cnblogs.com/lmfe ...
- 关于我们 HerlMax(赫马克斯),奢侈品顶级服装高级定制品牌!
关于我们 HerlMax(赫马克斯),奢侈品顶级服装高级定制品牌! HerlMax品牌拥有着纯正悠远的意大利高级定制文化,带着对神秘东方的向往,荣耀登入中国市场.