Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void main() {
- int n; //nombre entré par l'utilisateur
- int prev; //nombre précédant
- int p; //position courante
- int suite = 1; //nombre de valeur dans la suite en cours
- int max = 0; //nombre de valeur dans la plus grande suite
- int pos = 0; //position de départ de la dernière plus grande suite
- int cpt = 1; //compteur de suite(s) ayant le plus grand nombre de valeurs
- printf("Entrer un nombre: ");
- scanf("%d", &n);
- if(n!=100) {
- p = 1;
- prev = n;
- printf("Entrer un nombre: ");
- scanf("%d", &n);
- while(n != 100) {
- p = p + 1;
- if(prev == n-1) {
- suite = suite + 1;
- } else {
- if(suite >= max) {
- if(suite > max) {
- max = suite;
- cpt = 1;
- } else if ( suite == max ) {
- cpt = cpt + 1;
- }
- pos = p - suite;
- }
- suite = 1;
- }
- prev = n;
- printf("Entrer un nombre: ");
- scanf("%d", &n);
- }
- if(suite >= max) {
- if(suite > max) {
- max = suite;
- } else if ( suite == max ) {
- cpt = cpt + 1;
- }
- pos = p + 1 - suite;
- }
- printf("Nombres vaildes saisis : %d\n", p);
- printf("Dernière plus grande suite : %d\n", max);
- printf("Sa position de départ : %d\n", pos);
- printf("Suites de %d nombres : %d\n", max, cpt);
- } else {
- printf("Aucun nombre valide saisi\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement