ICode9

精准搜索请尝试: 精确搜索
  • 桶排序2021-10-16 21:02:27

    /** * 桶排序 */ public class BucketSort { public static void main(String[] args) { int[] array = {23,14,47,71,32}; int digit = digit(array); bucketSort(array, 0, array.length - 1, digit); for (int i : array) {

  • C++ 将整数转为英文2021-10-15 18:29:59

    这几天帮香港那边一同学看代码,题目大概要求是输入整数,输出英文。 类似如下: 然后我是在同学写的基础上帮改的,感觉有点收藏意义,于是打算在此记录一下。 反正我感觉有点冗余了,我自己写可能会写的不太一样。 或许有错误没发现,发现了可以帮忙指正一下。 #include <iostream> using n

  • 将数字串转化为字符串的子函数2021-10-13 20:03:08

    #include<bits/stdc++.h> using namespace std; string tostring(int a) { int t,digit=0,i,l=1; t=a; while(t) //判断n有几位 { t/=10; digit++; l*=10; } strin

  • java大白入门实例14之《对整数反转》2021-10-13 14:31:26

    使用 while循环 或者 for循环 实现对整数反转: 原理:先初始化一个反向变量res,对整数依次取余,每次取余都在反向变量基础上乘10再加余数,通过层层累加达到数字反转的结果。  public class java_14 { public static void main(String[] args) { int num = 98657;

  • POJ3126 Prime Path2021-10-11 17:02:39

    Prime Path 描述:The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter of security to change such things every now

  • 统计英文字母和数字字符2021-10-10 21:01:27

    本题要求编写程序,输入10个字符,统计其中英文字母、数字字符和其他字符的个数。 输入格式: 输入为10个字符。最后一个回车表示输入结束,不算在内。 输出格式: 在一行内按照 letter = 英文字母个数, digit = 数字字符个数, other = 其他字符个数 的格式输出。请注意,等号的左右各有一

  • 零基础学C/C++168——统计数字2021-10-10 10:59:00

    题目描述 定义并调用函数countdigit(number, digit),它的功能是统计整数number中数字digit的个数,如countdigit(10090, 0)的返回值是3. 在主函数中定义并调用该函数,统计任意一个输入整数中某数字的个数。 输入 输入为多组测试数据。 输入2个非负整数,分别是n(0 <= n <= 10000000000

  • 6-1 使用函数统计指定数字的个数 (15 分)2021-10-05 22:00:31

    函数接口定义: int CountDigit( int number, int digit ); 裁判测试程序样例: #include <stdio.h> int CountDigit( int number, int digit ); int main() { int number, digit; scanf("%d %d", &number, &digit); printf(“Number of digit %d in %d: %d\n”, digit

  • 位运算相关的2021-10-05 19:31:01

    二进制转化为16进制 参考lc题目 这道题目是32位的数,二进制32位,从右到左的方向为低位到高位,每4位为一组,通过这个公式 (nums>>(4×i)) & 0xf 将这4位转化为对应的16进制数(取值范围为0到15(即16进制的f)) 对于负整数,由于最高位一定不是 0,因此不会出现前导零。对于零和正整数,可能

  • Digital Roots2021-10-04 23:34:54

    The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process

  • leetcode练习——回溯算法(电话号码的字母组合)2021-10-01 22:03:23

    给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 官方解法:https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/solution/dian-hua-hao-

  • 1066: 字符分类统计 C语言2021-09-27 13:02:28

    1066: 字符分类统计 时间限制: 1 Sec 内存限制: 128 MB 提交: 31403 解决: 17339 [状态] [讨论版] [提交] [命题人:admin] 题目描述 输入一行字符,以回车符作为输入结束的标志。统计其中英文字母、数字字符和其他字符的个数。 输入 多个字符,以回车符结束,回车符不作为有效字符

  • 代码练习:整数分解(输入一个整数,输出该整数各位数字)2021-09-26 18:30:34

    要求输入一个正整数,之后输出该数的各位数字。如:输入123,输出1,2,3 题目分析:要想拆分一个整数,首先要确认它的位数,之后再根据规律逐个拆分各位。 确认整数位数,就要使用Java中的length()函数,该函数可以计算出一个字符串类型的位数(注:空格也会算作一位),如: String a="Hello World";

  • 8-P-22021-09-22 22:34:12

    #include<stdio.h> int main(void) {     int a[10] = {0};     int digit, n;     printf("PLease enter a number:");     scanf_s("%d", &n);     while (n>0)     {         digit = n % 10;         a[digit]++;         n /= 10;  

  • js强制固定多少位小数2021-09-14 14:01:29

    // js强制固定多少位小数,是否四舍五入取决于round参数,默认四舍五入 function fixedDigit (vlue, digit=2, round=true) { if (round) { // 四舍五入 return (Math.round(parseFloat(vlue)*Math.pow(10,digit))/Math.pow(10,digit)).toFixed(digit) } else { // 不四

  • Codeforces Round #739 (Div. 3)--D2021-09-06 17:32:08

    题干: You are given an integer nn. In 11 move, you can do one of the following actions: erase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is "empty"); add on

  • 【题解】产生数 (集训day3)2021-08-23 18:01:17

    知识点:搜索+高精度。 大体思路: 1.  我们求出每一位可以变换的数的个数。再用乘法原理一个一个乘起来。乘的时候用高精度。 2.  怎么求每一位可以变换成哪些数呢?搜索。 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using n

  • Digit Counts2021-08-22 14:34:52

    Source Count the number of k's between 0 and n. k can be 0 - 9. Example if n=12, k=1 in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], we have FIVE 1's (1, 10, 11, 12) 题解 找出从0至整数 n 中出现数位k的个数,与整数有关的题大家可能比较容易想到求模求余等方法,但其

  • [LeetCode] 233. Number of Digit One2021-08-19 23:33:44

    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. Example 1: Input: n = 13 Output: 6 Example 2: Input: n = 0 Output: 0 Constraints: 0 <= n <= 109 数字 1 的个数。 给定一个整数 n,计算所

  • 巧解进制转换题2021-08-02 11:58:53

    问题 1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and th

  • C语言:习题5-5 使用函数统计指定数字的个数.2021-07-302021-07-30 22:29:55

    习题5-5 使用函数统计指定数字的个数 (15 分) 本题要求实现一个统计整数中指定数字的个数的简单函数。 函数接口定义: int CountDigit( int number, int digit ); 其中number是不超过长整型的整数,digit为[0, 9]区间内的整数。函数CountDigit应返回number中digit出现的次数。 裁判

  • HDU - 3555 Bomb(数位DP)2021-07-30 17:32:03

    HDU - 3555 Bomb 题目分析:查出从1~n之间有多少个49 数位DP #include<cstdio> #include<cstring> typedef long long ll; ll dp[22][4],digit[22]; void init() { dp[0][0]=1; for(int i=1;i<21;i++) { dp[i][0]=dp[i-1][0]*10-dp[i-1][1];//代表长度为len不含49的方案

  • 【LeetCode笔记】剑指Offer 43. 1~n 整数中1出现的次数(Java、数位dp、偏数学)2021-07-22 16:33:38

    文章目录 题目描述思路 && 代码 打卡第九天啦~ 题目描述 有点像数字序列中的某一位 思路 && 代码 主体思路:从低到高,计算出每一位出现的1的个数。三种情况:n的当前位为0、为1、为其他值。这里和数位dp的思想相关(但是博主没怎么看= =,有兴趣可以去了解了解)仔细想想确实是dp

  • LeetCode_每日做题笔记7/212021-07-21 09:03:11

    一级目录 链接: leetcode. <第一道>整数反转 题目、答案 给你一个 32 位的有符号整数 x ,返回将 x 中的数字部分反转后的结果。 如果反转后整数超过 32 位的有符号整数的范围 [−231, 231 − 1] ,就返回 0。 假设环境不允许存储 64 位整数(有符号或无符号)。 ##Python class

  • LeetCode 13. 罗马数字转整数2021-07-08 18:58:37

    罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符          数值 I             1 V             5 X             10 L             50 C             100 D             500 M             1000 例如, 罗马数字 2 写做 

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有