Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main(){
- char str1[]={"201-15-13827"};
- int i,j,sum=0,count=0;
- char str2[15];
- char nm[10]={'0','1','2','3','4','5','6','7','8','9'};
- for(i=0,j=0;i<strlen(str1);i++,j++){
- if(str1[i]!='-'){
- str2[j]=str1[i];
- count++;
- }
- else{
- j--;
- }
- }
- for(i=0;i<strlen(str2);i++){
- for(j=0;j<10;j++){
- if(str2[i]==nm[j]){
- sum=sum + j;
- }
- }
- }
- printf("%s\n%d\n",str2,sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement