SHOW:
|
|
- or go back to the newest paste.
1 | // creare un programma che da input un insieme di strinche. | |
2 | // il programma per ogni stringa immessa stampi le lettere doppie presenti nella | |
3 | // stringa termina quando รจ uguale a end | |
4 | #include <stdio.h> | |
5 | #include <stdlib.h> | |
6 | #include <string.h> | |
7 | #define SIZE 100 | |
8 | ||
9 | int main(void) { // inizio main | |
10 | // dichiaro le variabili | |
11 | char str[SIZE]; | |
12 | char end[] = "end"; | |
13 | int doppie = 0; | |
14 | ||
15 | while (strcmp(str, end) != 0) { // inizio while | |
16 | puts("Inserisci la stringa"); | |
17 | scanf("%99s", str); | |
18 | ||
19 | for (int i = 0; i < SIZE - 1; i++) { // inizio for | |
20 | if (str[i] == str[i + 1]) { // inizio if | |
21 | doppie++; | |
22 | printf("%s%d", "Le doppie sono: ", doppie); | |
23 | } // fine if | |
24 | ||
25 | } // fine del for | |
26 | ||
27 | } //fine while | |
28 | ||
29 | } // fine main |