Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int summa(char* str);
- int main()
- {
- int const size = 50;
- char str[size] = " ";
- char str1[size];
- int k = 1000;
- int i = 0;
- while (str[0] != '\n') {
- fgets(str, size, stdin);
- if (summa(str) < k) {
- k = summa(str);
- while (str[i] != '\n') {
- str1[i] = str[i];
- i++;
- }
- i = 0;
- }
- }
- printf("%s", str1);
- return 0;
- }
- int summa(char* str) {
- int i = 0;
- int sum = 0;
- while (str[i]) {
- if (str[i] >= '0' && str[i] <= '9') {
- sum = sum + str[i] - '0';
- }
- i++;
- }
- return sum;
- }
- if (s[i] != ' ') {
- count *= 10;
- count += s[i] - '0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement