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

为什么WA????哪位路过的大虾帮个忙~~感激涕零

Posted by snowfall at 2008-04-01 21:12:20 on Problem 2105 and last updated at 2008-04-19 23:44:15
#include<iostream>

using namespace std;

int a[8]={128,64,32,16,8,4,2,1};

int main()
{
      int i,j,k,m,temp;
      char ip[8][32];
      int IP[8][4]={0}; 
      
      scanf("%d",&m);
      getchar();
      
      for(i=0;i<m;i++)
      {    for(j=0;j<32;j++)
            scanf("%c",&ip[i][j]);
           getchar();
      } 
                           
         
      for(i=0;i<m;i++)
       {
                    temp=0;
                    for(j=0;j<4;j++)  
                     {
                                      IP[i][j]=0;
                                      for(k=temp;k<8+temp;k++)
                                      {      IP[i][j]=(ip[i][k]-'0')*a[k-temp]+IP[i][j];
                                      
                                      }      
                                      temp+=8;
                     } 
                      
       }     
       
       for(i=0;i<m;i++)
           printf("%d.%d.%d.%d\n",IP[i][0],IP[i][1],IP[i][2],IP[i][3]);
      
      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