Sunday, 18 November 2018

uva problem 10945 Mother bear solution

  1. #include<bits/stdc++.h>
  2. #include<string.h>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.     char str[100000],r[100000],cas[100000];
  8.  
  9.     while(gets(str)){
  10.             int j=0;
  11.             if(strcmp(str,"DONE")==0) break;
  12.             for(int i=0;i<strlen(str);i++){
  13.                 if(isalpha(str[i])) r[j++]= str[i];
  14.             }
  15.      for(int i=0;i<j;i++) {
  16.         if(r[i]>='a' && r[i]<='z') r[i]=r[i]-32;
  17.      }
  18.       for(int i=0;i<j;i++)
  19.        {
  20.         cas[j-1-i]=r[i];
  21.        }
  22.        int c=0;
  23.        for(int i=0;i<j;i++){
  24.         if(cas[i]==r[i]) c++;
  25.        }
  26.        if(c==j) cout<<"You won't be eaten!\n";
  27.        else cout<<"Uh oh..\n";
  28.     }
  29.     return 0;
  30. }

No comments:

Post a Comment

variable declaration of c program

#include <stdbool.h> #include<bits/stdc++.h> #include <stdio.h> #include <string.h> #include <std...