Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Last active February 15, 2020 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save invatainfo/040f610ff410e8d3217811949ff40f56 to your computer and use it in GitHub Desktop.
Save invatainfo/040f610ff410e8d3217811949ff40f56 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string.h>
using namespace std;
int main() {
int n, no_words = 0, i, exista_mari = 0, exista_mici = 0;
char text[101], words[100][100], *p;
cin >> n;
cin.get();
cin.getline(text, 100); //citim tot textul
p = strtok(text, " ");
while (p != NULL) {
strcpy(words[no_words++], p);
if (strlen(p) >= n) {
exista_mari = 1;
} else {
exista_mici = 1;
}
p = strtok(NULL, " ");
}
if (exista_mari == 0 || exista_mici == 0) {
cout << "nu exista" << endl;
return 0;
}
for (i = 0; i < no_words; i++) {
if (strlen(words[i]) >= n) {
cout << words[i] << endl;
}
}
for (i = 0; i < no_words; i++) {
if (strlen(words[i]) < n) {
cout << words[i] << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment