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 explode 用法详解
定义和用法explode() 函数把字符串分割为数组. 语法explode(separator,string,limit)参数 描述 separator 必需.规定在哪里分割字符串.string 必需 ...
- C语言杂记 -- 简陋的<深入理解计算机系统>笔记
程序的表示 l 32位64位操作系统是由CPU寄存器的位数决定,即虚拟寻址的范围为2^32.2^64. l 字节的大端小端法是以字节为基本单位的:比如十进制的7在十六位机器上表示 · 地址 100 1 ...
- MPMoviePlayerController 电影播放器—备用
MPMoviePlayerController 与AVAudioPlayer有点类似,前者播放视频,后者播放音频,不过也有很大不同,MPMoviePlayerController 可以直接通过远程UR ...
- Spark 资源调度及任务调度
1. 资源分配 通过SparkSubmit进行提交应用后,首先会创建Client将应用程序(字节码文件.class)包装成Driver,并将其注册到Master.Master收到Client的注册请 ...
- Altium中Fill,Polygon Pour,Plane的区别和用法
Fill:表示绘制一块实心的铜皮,将区域中的所有连线和过孔连接在一块,而不考虑是否属于同一个网络.假如所绘制的区域中有VCC和GND两个网络,用Fill命令会把这两个网络的元素连接在一起,这样就有可能 ...
- IBM总裁郭士纳总结的四类人
IBM总裁郭士纳总结的四类人, 您属于哪一种呢-欢迎就此话题发表评论 积极采取行动促使事件发生的人 被动接受所发生事件的人 对事件持旁观者心态的人 什么事都不关心的人
- json转换为键值对辅助类
/// <summary> /// json转换为键值对辅助类 /// </summary> public class JsonParser { private static ...
- Android 利用Application对象存取公共数据
本文章来给大家介绍Android 利用Application对象存取公共数据. Android系统在运行每一个程序应用的时候,都会创建一个Application对象,用于存储与整个应用相关的公共变量. ...
- 在QLabel上点击获得的效果
一般说只在button中点击获得事件,作出相应的反应.而往往需要在QLabel上作出点击和触碰的效果. 我用qlabel做出了一个效果,当鼠标碰到label区域,label底下出现一条线,离开后线条消 ...
- 几年前再用exjts4,如今extjs5发布了,技术更新快,每次给人惊喜
我们非常高兴的宣布,Sencha Ext JS 5 beta版本开始进行公测了.这个beta版本可以让你.我们Sencha社区来对我们的Ext JS 5的工作进度进行评测.对于所以Ext JS开发人员 ...