Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:用java的pow函数,一句话

Posted by me2002 at 2007-12-30 21:03:16 on Problem 3199
In Reply To:用java的pow函数,一句话 Posted by:superman2006 at 2007-08-11 15:05:55
#include<stdio.h>
#include<iostream>
using namespace std;


int main(void)
{
    char str[31];
    int n,d;
    scanf("%d%d",&n,&d);
    while(n||d)
    {
        memset(str,'0',sizeof(str));
        str[30]=0;
        str[29]=n+'0';
       // puts(str);
       if(n==10)
       {
              printf("1");
              int sum=0;
              while(d--)
                printf("0");
              printf("\n");
              scanf("%d%d",&n,&d);
              continue;
              
       }
       else if(d==0)
       {
              cout<<"1\n";
                 scanf("%d%d",&n,&d);
              continue;
              
              
       }
        while(d!=1)
        { 
             int flag=0;
              for(int i=29;i>=0;i--)
              {
                            flag=n*(str[i]-'0')+flag;
                    
                            str[i]=flag%10+'0';
                            flag=flag/10;
                            
              }
           
               d--;
        }
        int k=0;
    for(k=0;str[k]=='0';k++);
     puts(str+k);
  
        scanf("%d%d",&n,&d);
        
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator