-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNumCarpetas.cpp
More file actions
50 lines (40 loc) · 1.1 KB
/
Copy pathNumCarpetas.cpp
File metadata and controls
50 lines (40 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 100
int main(){
char carpetas[SIZE][SIZE],d;
int num,sum,cont = 0,piv = 1;
printf("Ingrese la cantidad de carpetas: ");
scanf("%d",&num);
while((d = getc(stdin)) != '\n' && d != EOF);
for(int i = 0; i < num; i++)
{
printf("Nombre de la carpeta %d: ", i + 1);
gets(carpetas[i]);
}
printf("Numero a sumar: ");
scanf("%d",&sum);
while((d = getc(stdin)) != '\n' && d != EOF);
for(int i = 0; i < num; i++)
{
cont = 0;
piv = 1;
int largo = strlen(carpetas[i]) - 1;
for(int j = largo;j >= 0; j--)
{
if(carpetas[i][j] >= '0' && carpetas[i][j] <= '9')
{
cont += (carpetas[i][j] - '0') * piv;
}
piv *= 10;
}
cont += sum;
for(int j = 0; j <= largo; j++){
if(carpetas[i][j] >= '0' && carpetas[i][j] <= '9') continue;
printf("%c", carpetas[i][j]);
}
printf("%d \n", cont);
}
return 0;
}