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 ...
随机推荐
- Python入门100例题
原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/11/05/2755107.html 无论学习哪门计算机语言,只要把100例中绝大部分题目都做一遍, ...
- DotNET知识点总结四(笔记整合)
1.枚举:本质是类 如果为第一个枚举赋了一个int值,那么后面的枚举项依次递增 可以将枚举强转成他所代表的int值 C#的枚举项都是常量(可以用Reflector查看literal的IL源码) 因为枚 ...
- 编译TWRP-recovery教程及源码地址
TWRP这个是一个老外的开源项目,全称Team-Win-Recovery-Project Source:https://github.com/TeamWin/Team-Win-Recovery-Pro ...
- RAILS 4 ON RUBY的AJAX实现过程
XXX,最近在笨手笨脚的写一个自动化SVN更新的WEB操作小平台, 这次决定用RAILS 4实现. 但因为网上的教材都是以3或2版本实现的.所以这次搞了不少弯路,现总结如下: 相关的VIEW代码: & ...
- C51系列RAM寄存器表
特殊功能寄存器地址表 SFR 符号 字节 地址 位地址和位名称 D7 D6 D5 D4 D3 D2 D1 D0 P0口 P0 80H P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0. ...
- BZOJ3433: [Usaco2014 Jan]Recording the Moolympics
3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 55 So ...
- 30种IT技能让你年薪过10万美元!
科技行业的高薪岗位向来不少,但在不断变化的职场中,热门技能却随时在变:今天的热门技术,明天可能就会过时.美国求职网站 Dice.com 最近发布了 2015 年薪酬报告,通过对 23,470 位 IT ...
- bfs 记录和打印最短路径
Poj3984 迷宫问题 #include <iostream> #include <algorithm> #include <cstdio> #include & ...
- Cortex-M3 FLASH 日志文件系统
本文简要介绍一下本人在Cortex-M3系统的STM32F10x芯片上开发的一个日志文件系统(与其说是系统,不如说是小小的库).该库的特点是将在STM32F10x芯片上处理数据(历史记录)变得简单可靠 ...
- 【Ruby on Rails 学习一】ubuntu14.04配置rvm与ruby
要安装ruby,首先要安装rvm,借助rvm安装ruby rvm 的全称是 Ruby Version Manager ,是一款由 Wayne E. Seguin 开发的一款命令行工具.rvm 能够让 ...