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

为什么同样的代码C++能AC 但是C 就不行呢????????????

Posted by Cunch at 2009-09-10 22:41:03 on Problem 2190
#include<stdio.h>
int main(){
  int i,j,m,k,sum,index;
  bool Find;
  char a[20];
  while( gets(a)){
      i=0;
	  k=10;
	  sum=0;
	  Find = false;
	  while(a[i]!='\0'){
		  if(a[i]=='?'){
		    index = i;
		  }else if(a[i]=='X'){
		     sum += 10;
		  }else {
		     sum += (a[i]-'0')*k;
		  }
		  k--;
		  i++;
	  }

	  if(index!=9){
      
	  for(j=0;j<=9;j++){
		  if((sum+(10-index)*j)%11==0){
		    printf("%d\n",j);
		    Find = true;
			break;
		  }
	  }
      if (Find == false){
	    printf("-1\n");
	  }
	  }else {
		  m = sum%11;
		  if(m==0)
		   printf("0\n");
		  else{
			if(m!=1)
		    printf("%d\n",11-m);
	        else 
		    printf("X\n");
		  }
	  }
	 
	  }

  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