1. 程式人生 > >acm題為什麼總是出現wrong answer。。。求大神救助

acm題為什麼總是出現wrong answer。。。求大神救助

#include<stdio.h>
int main()
{
 char c[100];
 char* p, *pm, *head;
 int sh;
 
 p = c;
 pm = c;
 head = c;

 
 while(gets(c))
 {
  pm =c;
  if(*p <= 'Z')
  {
   sh = 1;
  }
  else
  {
   sh = 0;
  }
  
  while(*p != '\0')
  {
   if(((*p+32) > *pm) && sh == 0)
   {
    if('A' <= *p && *p <= 'Z')
    {
     pm = p;
     sh = 1;
    }
   }
   if((*p > *pm) && sh == 1)
   {
    if('A' <= *p && *p <= 'Z') 
    {
     pm = p;
     sh = 1;
    }
   }
   if(*p > *pm && sh == 0)
   {
    if(*p >= 'a')
    {
     pm = p;
     sh = 0;
    }
   }
   if(((*p-32) > *pm) && sh == 1)
   {
    if(*p >= 'a')
    {
     pm = p;
     sh = 0;
    }
   
   }
   p++;
  }
  
  p = c;
  
  while(*p != '\0')
  {
   printf("%c", *p);
   if(*p == *pm || ((*p+32) == *pm) || ((*p-32) == *pm))
   {
    printf("(max)");
   }
   p++;
   
  }
  printf("\n");
  p = c;
 }
 
 return 0;
}