Created
December 8, 2014 19:58
-
-
Save Evshved/46503999c1fdbd6f9cf8 to your computer and use it in GitHub Desktop.
7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vcl.h> | |
| #include <stdio.h> | |
| #include <conio.h> | |
| #include <math.h> | |
| #include <stdlib.h> | |
| #include <classes.hpp> | |
| #pragma hdrstop | |
| int main() | |
| { | |
| int sum = 0, i=0,n,count,b; | |
| char Str[100]; | |
| fflush(stdin); | |
| printf("Input string "); | |
| gets(Str); | |
| n = strlen(Str); | |
| for (count=0;count<n;count++) { | |
| TryStrToInt(Str[count],b); | |
| switch (b){ | |
| case 1: sum+=1; | |
| break; | |
| case 2: sum+=2; | |
| break; | |
| case 3: sum+=3; | |
| break; | |
| case 4: sum+=4; | |
| break; | |
| case 5: sum+=5; | |
| break; | |
| case 6: sum+=6; | |
| break; | |
| case 7: sum+=7; | |
| break; | |
| case 8: sum+=8; | |
| break; | |
| case 9: sum+=9; | |
| break; | |
| } | |
| } | |
| printf("%d",sum); | |
| getchar(); | |
| getchar(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment