1 solutions
-
0
C :
#include <stdio.h> #define BASE 10 int main(void) { int n, digitsum; scanf("%d", &n); digitsum = 0; while(n) { digitsum += n % BASE; n /= BASE; } printf("%d\n", digitsum); return 0; }
C++ :
#include<bits/stdc++.h> using namespace std; int shu; int he=0; int main() { cin>>shu; while(shu>0) { he=he+shu%10; shu=shu/10; } cout<<he; return 0; }
- 1
Information
- ID
- 10316
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By