ВОПРОС · Q&A

Помогите перевести с C++ на СИ

0 ответов 2,1 тыс.
AI-выжимка обсуждения скоро

Краткие тезисы обсуждения со ссылками на ключевые ответы появятся здесь.

Автор вопроса
C++:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
 
int main()
{
    int i=0, count=0;
    string s, s1, word;
    cout << "String:\n";
    getline(cin, s);     
    
    while (s[i])
        {
        if (s[i]=='a') count++;
        i++;
        }   
        
    if (count)
    {
    stringstream words(s);
    while (words >> word)
    {
        i=count=0;
        while (word[i])
        {
            if (word[i]=='a') count++;
            i++;
        }   
        if (count<=2) s1+=word+" ";       
    }
    s=s1.erase(s1.size()-1);
    cout << s <<"\n";
    }
    else cout << "Letter 'a' is absent\n";
    
system("pause");
return 0;
}
 

Ещё по теме