Advertisement
dsdeep

unkniown

Aug 18th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main(){
  4.      char str1[]={"201-15-13827"};
  5.      int i,j,sum=0,count=0;
  6.      char str2[15];
  7.      char nm[10]={'0','1','2','3','4','5','6','7','8','9'};
  8.      for(i=0,j=0;i<strlen(str1);i++,j++){
  9.         if(str1[i]!='-'){
  10.             str2[j]=str1[i];
  11.             count++;
  12.         }
  13.         else{
  14.             j--;
  15.         }
  16.      }
  17.      for(i=0;i<strlen(str2);i++){
  18.         for(j=0;j<10;j++){
  19.           if(str2[i]==nm[j]){
  20.              sum=sum + j;  
  21.           }
  22.         }
  23.      }
  24.  
  25.      printf("%s\n%d\n",str2,sum);
  26.      return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement