桑海

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  算法竞赛入门经典

算法学习
摘要:问题描述:输入两数,统计两数相加的进位个数My Code://精简代码#include<iostream>using namespace std;int main(){ int a, b, c, cnt; while(cin >> a >> b) { c = cnt = 0; while(a || b) { c = ((a%10 + b%10 + c) > 9) ? 1 : 0; cnt += c; a /= 10; b /= 10; } ... 阅读全文
posted @ 2012-11-08 21:29 桑海 阅读(457) 评论(1) 推荐(1)

摘要:题目描述://--------------------C_Style---------------- #include<stdio.h> #include<string.h> int main() { char word[100]; scanf("%s", word); int len = strlen(word); for(int i = 1; i <= len; ++i) if(len % i == 0) { int ok = 1; for(int j = i; j <... 阅读全文
posted @ 2012-11-07 20:47 桑海 阅读(249) 评论(0) 推荐(0)

摘要:1 //------------C_Style----------------- 2 3 #include<stdio.h> 4 5 void main() 6 { 7 char *str = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./"; 8 int c; 9 printf("Enter a string(Ctr+Z to end):\n");10 while((c = getchar()) != EOF)11 {12 for(int ix = 1; str[ix] & 阅读全文
posted @ 2012-11-07 19:38 桑海 阅读(338) 评论(0) 推荐(0)