摘要:问题描述:输入两数,统计两数相加的进位个数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; } ...
阅读全文
随笔分类 - 算法竞赛入门经典
算法学习
摘要:问题描述:输入两数,统计两数相加的进位个数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; } ...
阅读全文
摘要:题目描述://--------------------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 <...
阅读全文
摘要: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] &
阅读全文
|