eolymp
bolt
Try our new interface for solving problems
Problems

Number of sentences

published at 1/6/24, 10:31:47 pm

include <stdio.h>

include <string.h>

include <stdbool.h>

int main(){ char n[250]; int say=0; bool s=true; gets(n); int size=strlen(n); for(int i=0 ;n[i]!='\0' ;i++){ if(n[i]=='.' || n[i]=='?' || n[i]=='!'){ s=true; }

    else if(s){
        say++;
        s=false;
    }
}
printf("%d",say);

return 0;

}

published at 1/17/24, 12:05:41 pm

c# - 100%

using System; namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { string s = Console.ReadLine(); if (s.Length == 0) Console.WriteLine(0); else if (s.Length == 1) Console.WriteLine(1); else { int c = 1; for (int i = 0; i < s.Length - 1; i++) { if (s[i] == '!' || s[i] == '?' || s[i] == '.') { if (s[i + 1] == ' ') c++; } } Console.WriteLine(c); } Console.ReadKey(); } } }

published at 3/11/24, 2:00:58 pm

include <stdio.h> include <string.h> include <stdbool.h> int main(){ char n[250]; int say=0; bool s=true; gets(n); int size=strlen(n); for(int i=0 ;n[i]!='\0' ;i++){ if(n[i]=='.' || n[i]=='?' || n[i]=='!'){ s=true; }

else if(s){
    say++;
    s=false;
}

} printf("%d",say);

return 0; }