Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <Foundation/Foundation.h>
  2. #import <stdio.h>
  3.  
  4.  
  5.  
  6. int main( int argc, const char *argv[] ) {
  7.         int T,Z,A,B;
  8.         char string[17];
  9.         BOOL odd = YES;
  10.             scanf("%d",&T);
  11.             NSMutableArray* array = [[NSMutableArray alloc]init];
  12.             NSMutableArray* oddArray = [[NSMutableArray alloc]init];
  13.             for ( int i = 1;i<=T;i++){
  14.            
  15.            
  16.                 scanf("%16s",string);
  17.                
  18.                 for (int j = 0;j<=16;j++) {
  19.                     int X = string[j] - '0';
  20.                
  21.                     [array insertObject:[NSNumber numberWithInteger:X] atIndex:j];
  22.                 }
  23.                
  24.            
  25.                 NSArray* reversedArray = [[array reverseObjectEnumerator] allObjects];
  26.            
  27.                 for (int k = 0;k < [reversedArray count];k++) {
  28.                 int theNum = [[reversedArray objectAtIndex:k] integerValue];
  29.                
  30.                 if  (odd){
  31.                     A = A + theNum;
  32.                 } else {
  33.                     B  += theNum/5 + (2*theNum) % 10;                  
  34.                    
  35.                 }
  36.                
  37.                    
  38.                 odd = !odd;
  39.                
  40.                  
  41.               }
  42.             int sum = A+B;
  43.             printf("%d\n",sum);
  44.             if(sum%10){
  45.               printf("NO");
  46.             } else {
  47.               printf("YES");
  48.             }
  49.         }
  50.    
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement