agrego practicas
This commit is contained in:
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: gcc build active file",
|
||||
"command": "/usr/bin/gcc",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
este es un archivo
|
||||
de texto
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int count_words(char*);
|
||||
|
||||
int main(void){
|
||||
|
||||
char buffer[50];
|
||||
int total_words = 0;
|
||||
|
||||
while((fgets(buffer, sizeof(buffer), stdin)) != NULL){
|
||||
total_words += count_words(buffer);
|
||||
}
|
||||
|
||||
printf("El total de palabras es: %d\n", total_words);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count_words(char* line){
|
||||
int palabras = 0;
|
||||
bool hay_espacio = false;
|
||||
|
||||
printf("line: %s", line);
|
||||
|
||||
if((line[0] != ' ') && strlen(line) > 0){
|
||||
palabras++;
|
||||
}
|
||||
|
||||
for(int i = 0; i < strlen(line); i++){
|
||||
if(line[i] == ' '){
|
||||
hay_espacio = true;
|
||||
}
|
||||
|
||||
if((line[i] != ' ') && (line[i] != '\n') && (hay_espacio)){
|
||||
palabras++;
|
||||
hay_espacio = false;
|
||||
}
|
||||
}
|
||||
return palabras;
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user