zoukankan      html  css  js  c++  java
  • Google考试题:定义控制台应用程序的入口点《节选自froster.>

     1// MyCountOne.cpp : 定义控制台应用程序的入口点。
     2//
     3
     4#include "stdafx.h"
     5#include <iostream>
     6#include <string>
     7#include <math.h>
     8#include <windows.h>
     9#include <ctime>
    10
    11using namespace std;
    12unsigned long count = 0;
    13unsigned long F(int buf[], int start );
    14unsigned long T[20];
    15
    16void CaculateT(void)
    17{
    18    int i;
    19    T[1= 1;
    20
    21    for(i=2;i<10;i++)
    22    {
    23        T[i] = pow(10,(i-1)) + 10 * T[i-1];
    24    }

    25}

    26
    27int _tmain(int argc, _TCHAR* argv[])
    28{
    29    unsigned long temp, M = 199900;
    30    int i;
    31    int buf[20];
    32    DWORD start, end, usetime;
    33    start = GetTickCount();
    34    
    35    CaculateT();
    36
    37    do
    38    {
    39        i=1;
    40        temp = M;
    41        while( temp > 0 )
    42        {
    43            buf[i++= temp % 10;
    44            temp /= 10;
    45        }

    46
    47        cout<<M<<"->"<<F(buf, i-1)<<"  ";
    48        if(M%5==0
    49            cout<<endl;
    50    }
    while(M++<199981);
    51
    52    end = GetTickCount();
    53    usetime = start - end;
    54    cout<<"use "<<usetime<<"milliseconds"<<endl;
    55
    56    cout<<M-1;
    57
    58
    59    return 0;
    60
    61
    62}

    63
    64unsigned long F(int buf[], int start)
    65{
    66
    67    unsigned long temp = 0;
    68    if(start==1)
    69    {
    70        if(buf[start] == 0)
    71            return 0;
    72        else
    73            return 1;
    74    }

    75
    76    if( buf[start] == 1)
    77    {
    78        temp = 0;
    79        for(int i=start-1; i>0; i--)
    80            temp = temp * 10 + buf[i];
    81
    82        return ( T[start-1+ temp + 1 + F(buf, start - 1) );
    83    }

    84    else if(buf[start] == 0)
    85    {
    86        return F(buf, start - 1);
    87    }

    88    else
    89    {
    90        return ( buf[start] * T[start-1+ pow(10, start - 1+ F(buf, start - 1) );
    91    }

    92
    93}
  • 相关阅读:
    spring cloud 和 阿里微服务spring cloud Alibaba
    为WPF中的ContentControl设置背景色
    java RSA 解密
    java OA系统 自定义表单 流程审批 电子印章 手写文字识别 电子签名 即时通讯
    Hystrix 配置参数全解析
    spring cloud 2020 gateway 报错503
    Spring Boot 配置 Quartz 定时任务
    Mybatis 整合 ehcache缓存
    Springboot 整合阿里数据库连接池 druid
    java OA系统 自定义表单 流程审批 电子印章 手写文字识别 电子签名 即时通讯
  • 原文地址:https://www.cnblogs.com/gredswsh/p/1827953.html
Copyright © 2011-2022 走看看