Utilisateur:Zulul/Wikimodule:langage C++ niveau1:Etudiant zulul

Wikimodule:langage C++ niveau 1
J'attends les devoirs :) ==> Voilà j'ai mis de quoi étudier !!

Inscription modifier

Nom d'étudiant : zulul

Inscription au module de C++ niveau 1 // REF

Bienvenu à toi et bon travail. N'hésite pas à poser des questions si tu as des pbs.
Quand commence ce module ?

Quand tu veux et à ton rythme ==> Tu indiques ta progression dans ta fiche de suivi et tu fais les exercices Merrheim 8 février 2006 à 13:25 (UTC)

Mon travail concenant ce module modifier

Semaine 1 modifier

Etudier le chapitre 1. ETAT : FAIT
Faire l'exercice 1 du chapitre 1.ETAT : FAIT - Zulul 8 février 2006 à 14:18 (UTC)

Semaine 2 modifier

Etudier le chapitre 2 ETAT : FAIT
Faire les 5 exercices du chapitre 2.ETAT : FAIT - Zulul 8 février 2006 à 16:30 (UTC)

Semaine 3 modifier

Etudier le chapitre 3 ETAT : FAIT - Zulul 11 février 2006 à 12:38 (UTC)
Faire les exercices de 1 à 5 du chapitre 3.ETAT : FAIT

Semaine 4 modifier

Faire les exercices de 6 à 9 du chapitre 3 ETAT : FAIT - Zulul 13 février 2006 à 22:26 (UTC)
Etudier le chapitre 4 ETAT : FAIT

Semaine 5 modifier

Faire les exercices de 1 à 10 du chapitre 4 ETAT : FAIT - Zulul 12 février 2006 à 14:35 (UTC)
Etudier le chapitre 5 ETAT : FAIT

Semaine 6 modifier

Faire les exercices de 11 à 20 du chapitre 4 ETAT : FAIT - Zulul 13 février 2006 à 22:15 (UTC)

Semaine 7 modifier

Etudier le chapitre 6 ETAT : FAIT - Zulul 15 mars 2006 à 19:00 (UTC)
Faire les exercices de 1 à 5 du chapitre 6 ETAT : FAIT - Zulul 15 mars 2006 à 19:00 (UTC)

Semaine 8 modifier

Faire les exercices de 6 à 10 du chapitre 6 ETAT : FAIT - Zulul 1 mai 2006 à 17:09 (UTC)
WIKI DS n° 1 ETAT : FAIT - Zulul 1 mai 2006 à 18:29 (UTC)

Semaine 9 modifier

Etudier le chapitre 7 ETAT : FAIT - Zulul 1 mai 2006 à 20:17 (UTC)
Faire les exercices de 1 à 5 du chapitre 7 ETAT : FAIT - Zulul 1 mai 2006 à 20:17 (UTC)

Semaine 10 modifier

Faire les exercices de 5 à 10 du chapitre 7 ETAT : FAIT - Zulul 17 mai 2006 à 17:00 (CEST)
Etudier le chapitre 8 ETAT : FAIT - Zulul 17 mai 2006 à 15:34 (CEST)

Semaine 11 modifier

Faire les exercices de 1 à 8 du chapitre 8 ETAT : FAIT - Zulul 19 mai 2006 à 19:40 (CEST)

Semaine 12 modifier

Etudier le chapitre 9 ETAT : FAIT - Zulul 2 juin 2006 à 12:43 (CEST)
Faire l'exercice 1 du chapitre 9 ETAT : FAIT - Zulul 2 juin 2006 à 12:44 (CEST)

Semaine 13 modifier

Faire les exercices 2 et 3 du chapitre 9 ETAT : FAITZulul 13 juin 2007 à 21:29 (CEST)
WIKI DS n° 2 ETAT : NON FAIT

Semaine 14 modifier

Etudier le chapitre 10 ETAT : NON FAIT
faire les exercices de 1 à 5 du chapitre 10 ETAT : NON FAIT

Semaine 15 modifier

Faire l'exercice 6 du chapitre 10 ETAT : NON FAIT

Semaine 16 modifier

WIKI DS n° 3 ETAT : NON FAIT

Questions sur le cours modifier

Semaine 1 modifier

cout et cin equivallent bien à stdin et stdout en C ?
oui. en C on utilise printf et scanf en C++ on utilisera plutôt cin avec lopérateur >> et cout avec l'opérateur <<

Semaine 2 modifier

peut-on déclarer des var non typées en c++ ? ==> NON Merrheim 14 février 2006 à 09:52 (UTC)
les identifiants sont cases sensitives ?
peut-on creer des vars dynamiques par concatenation du style // for(i=0;i<5;i++){ (int) "n"&i=i; } ou quelque chose dans le genre d'actionscript? - Zulul 8 février 2006 à 15:14 (UTC)
  • Les identifiants sont sensuibles à la casse. Les variables a et A sont 2 variables différentes.
  • Il n'est pas trop conseillé (et possible ici) de définir des variables dynamiquement pour cet exercice.


Zulul 8 février 2006 à 16:28 (UTC)

Comment fait-on pour faire un exposant n sur un double puisque le ^n ne marche pas ?
dans cmath, il doit y avoir une fonction pow qui calcule des puissanes à vérifier.

Semaine 3 modifier

comment faire pour ne pas imbriquer les if dans le 3.1 ?
y a-t'il un test du gente "[cond]?vrai:faux" comme en C ?
la condition C: "tout est vrai" sauf 0 qui est faut peut s'appliquer en C++ ?

oui mais je recommende de na pas utiliser ce genre d'"astuces"

dans le 3.3 pourquoi suis-je obligé de mettre (double) dans le pow ?

Zulul 11 février 2006 à 12:37 (UTC)

est-ce que vous fournirez vos solutions plus tard ?

J'ai commencé à mettre les solutions !Merrheim 14 février 2006 à 09:52 (UTC)

Semaine 4 modifier

Semaine 5 modifier

Semaine 6 modifier

Semaine 7 modifier

Semaine 8 modifier

Semaine 9 modifier

? y a t'il moyen de déclarer le prototype de la fonction comme en C et si oui comment ? Zulul 1 mai 2006 à 19:30 (UTC)

Semaine 10 modifier

? quelles sont les notations pour passer des tableaux en parametre en c++ ? * et ** ?

Semaine 11 modifier

Semaine 12 modifier

? Est-il préférable de faire des appels de fonction au sein des fonctions ou doit-on tout faire depuis le main ?

Semaine 13 modifier

Semaine 14 modifier

Semaine 15 modifier

Les travaux à rendre pour ce module modifier

Semaine 1 modifier

#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
   cout<<"Bonjour"<<endl<<"tout le monde";
   system("PAUSE");
   return EXIT_SUCCESS;
}

Semaine 2 modifier

/* 2.1 - SURFACE D'UN CHAMP */

#include <iostream>
using namespace std;

int main(int argc, char *argv[]){
 
 int lo,la;
    cout<<"Entrez longueur ";cin>>lo;
    cout<<"Entrez largeur ";cin>>la;
    cout<<"Surface : "<<la*lo<<endl;
    
    system("PAUSE");
    return 0;
}
// 2.1 PERIMETRE

    cout<<"Périmètre : "<<2*(la+lo)<<endl;
/* 2.2 - MOYENNE de 5 INT */

#include <iostream>
using namespace std;

int main(){
    
    int a,b=0;
    
    cout<<"Entrez entier 1 ";cin>>a;
    b = b+a;
    cout<<"Entrez entier 2 ";cin>>a;
    b = b+a;    
    cout<<"Entrez entier 3 ";cin>>a;
    b = b+a;    
    cout<<"Entrez entier 4 ";cin>>a;
    b = b+a;
    cout<<"Entrez entier 5 ";cin>>a;
    b = b+a;
    
    cout<<"Moyenne : "<<b/5<<endl;
    
    system("PAUSE");
    return 0;
}
/* CORR/ 2.2 - MOY de 5 INT */

#include <iostream>
using namespace std;

int main(){
    
    int a; double b=0;
    
    cout<<"Entrez entier 1 ";cin>>a;
    b = b+((double) a);
    cout<<"Entrez entier 2 ";cin>>a;
    b = b+((double) a);
    cout<<"Entrez entier 3 ";cin>>a;
    b = b+((double) a);   
    cout<<"Entrez entier 4 ";cin>>a;
    b = b+((double) a);
    cout<<"Entrez entier 5 ";cin>>a;
    b = b+((double) a);
    
    cout<<"Moyenne : "<<b/5<<endl;
    
    system("PAUSE");
    return 0;
}
// 2.3 PERMUTE 2 INT

#include <iostream>
using namespace std;

int main(){
 
 int A,B,TMP;
    cout<<"Entrez A ";cin>>A;
    cout<<"Entrez B ";cin>>B;
    TMP=A;A=B;B=TMP;
    cout<<"A = "<<A<<" et B = "<<B<<endl;
    
    system("PAUSE");
    return 0;
}
// 2.4 PRIX KG TOMATE TTC

#include <iostream>
using namespace std;

int main(){
 
 double pu,tva,nb;
    cout<<"Entrez Prix au kg ";cin>>pu;
    cout<<"Entrez Nbre de kg ";cin>>nb;
    cout<<"Entrez taux TVA ";cin>>tva;
    cout<<"Prix TTC : "<<(pu*nb)+(pu*nb)*(tva/100)<<endl;
    
    system("PAUSE");
    return 0;
}
// 2.5 DISTANCE ENTRE DEUX POINTS

#include <iostream>
#include <math.h>
using namespace std;

int main(){
 
 double x,y,tmp;
    cout<<"Entrez x1 ";cin>>x;
    cout<<"Entrez y1 ";cin>>y;
    cout<<"Entrez x2 ";cin>>tmp;
    x=x-tmp;
    cout<<"Entrez y2 ";cin>>tmp;
    y=y-tmp;
    cout<<"DISTANCE (x1,y1) et (x2,y2) : "<<sqrt(x*x+y*y)<<endl;
    
    system("PAUSE");
    return 0;
}

Semaine 3 modifier

// 3.1 AX+B=0

#include <iostream>
#include <cmath>
using namespace std;

int main(){
 
 int a,b;
 
    cout<<"Entrez a ";cin>>a;
    cout<<"Entrez b ";cin>>b;

    if ((a != 0) && (b != 0)) cout<<"Solution : "<<(double) b/a<<endl;
    else {if (b==0) cout<<"Tout x est solution"<<endl;
          if (a==0) cout<<"Pas de solution"<<endl;
    }
    
    system("PAUSE");
    return 0;
}
// 3.2 plus grand nombre

#include <iostream>
using namespace std;

int main(){
     
 int a,b=0;
 
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;

    cout<<"le plus grand nombre est : "<<b<<endl;
    
    system("PAUSE");
    return 0;
    
}
// 3.3 Equation du Second degre

#include <iostream>
#include <cmath>
using namespace std;

int main(){

 int a,b,c,delta;

    cout<<"Entrez a ";cin>>a;
    cout<<"Entrez b ";cin>>b;
    cout<<"Entrez c ";cin>>c;
    if (a==0){
       // Eq 1er degre
       if (b==0) cout<<"Pas de solution"<<endl;
       else {
            if (c==0) cout<<"Tout x est solution"<<endl;
            else cout<<"x = "<<(double) c/b<<endl;
            }
    }else{
       // Eq 2e degre
       delta=pow((double)b,2)-4*a*c;
       if (delta<0) cout<<"pas de solution"<<endl;
       else {
            if (delta==0) cout<<"x = "<<(double) -b/2*a<<endl;
            else{
                 cout<<"x1 = "<<(double) (-b - sqrt(delta))/2*a<<endl;
                 cout<<"x2 = "<<(double) (-b + sqrt(delta))/2*a<<endl;
            }
       }
    }
    
    system("PAUSE");
    return 0;

}
// 3.4 Deux droites

#include <iostream>
#include <cmath>
using namespace std;

int main(){

 double x1,x2,x3,x4,y1,y2,y3,y4,p1,p2,d1,d2; bool c1,c2;

    cout<<"Entrez A (x1,y1) ";cin>>x1;cin>>y1;
    cout<<"Entrez B (x2,y2) ";cin>>x2;cin>>y2;
    cout<<"Entrez C (x3,y3) ";cin>>x3;cin>>y3;
    cout<<"Entrez D (x4,y4) ";cin>>x4;cin>>y4;

    c1=((x1==x2)&&(y1==y2));
    c2=((x3==x4)&&(y3==y4));
    
    if (c1) cout<<"A et B confondus"<<endl;
    if (c2) cout<<"C et D confondus"<<endl;

    if(!(c1||c2)){
     // PENTES
     p1=((y1*1)-(y2*1))/((x1*1)-(x2*1));
     p2=((y3*1)-(y4*1))/((x3*1)-(x4*1));
     // DECALAGE
     d1=((x1*y2)-(x2*y1))/((x1*1)-(x2*1));
     d2=((x3*y4)-(x4*y3))/((x3*1)-(x4*1));
     
     if (p1 == p2) {
        if (d1 != d2)
           cout<<"AB et CD sont paralleles"<<endl;
        else
           cout<<"AB et CD sont confondues"<<endl;
     }else
        cout<<"AB et CD sont secantes"<<endl;
    }

    system("PAUSE");
    return 0;
}
// 3.5 Valeur absolue d'un int

#include <iostream>
using namespace std;

int main(){

 int x;

    cout<<"Entrez X ";cin>>x;

    if (x<0)
       cout<<"abs de x est "<<x-2*x<<endl;
    else
       cout<<"abs de x est "<<x<<endl;

    system("PAUSE");
    return 0;

}

Zulul 4 avril 2006 à 14:14 (UTC)

// 3.1 CORRECTION AX+B=0

#include <iostream>
#include <cmath>
using namespace std;

int main(){
 
 double a,b;
 
    cout<<"Entrez a ";cin>>a;
    cout<<"Entrez b ";cin>>b;

    if ((a==0)) {

       if (b==0){
          cout<<"tout x est solution"<<endl;
       }else{
          cout<<"pas de solution"<<endl;
       }       

    }else{       

       cout<<"Solution: "<<-b/a<<endl;

    }
    system("PAUSE");
    return 0;
}
// 3.2 plus grand nombre

#include <iostream>
using namespace std;

int main(){
     
 int a,b=0;
 
    cout<<"Entrez un nombre ";cin>>a;b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;
    cout<<"Entrez un nombre ";cin>>a;
    if (a>b) b=a;

    cout<<"le plus grand nombre est : "<<b<<endl;
    
    system("PAUSE");
    return 0;
    
}
// 3.4 Deux droites

#include <iostream>
#include <cmath>
using namespace std;

int main(){

 double x1,x2,x3,x4,y1,y2,y3,y4,p1,p2,d1,d2; bool c1,c2;

    cout<<"Entrez A (x1,y1) ";cin>>x1;cin>>y1;
    cout<<"Entrez B (x2,y2) ";cin>>x2;cin>>y2;
    cout<<"Entrez C (x3,y3) ";cin>>x3;cin>>y3;
    cout<<"Entrez D (x4,y4) ";cin>>x4;cin>>y4;

    c1=((x1==x2)&&(y1==y2));
    c2=((x3==x4)&&(y3==y4));
    
    if (c1) cout<<"A et B confondus"<<endl;
    if (c2) cout<<"C et D confondus"<<endl;

    if(!(c1||c2)){
                  
    // PENTES              
    if(x1-x2!=0){p1=(y1-y2)/(x1-x2);}else{p1=0;}
    if(x3-x4!=0){p2=(y3-y4)/(x3-x4);}else{p2=0;}
    
     // DECALAGE
     d1=y1-p1*x1;
     d2=y2-p2*x2;
     
     if (p1 == p2) {
        if (d1 != d2)
           cout<<"AB et CD sont paralleles"<<endl;
        else
           cout<<"AB et CD sont confondues"<<endl;
     }else
        cout<<"AB et CD sont secantes"<<endl;
        //PAR CRAMER
        cout<<"X : "<<d1*1-d2*1/p1-p2<<endl;
        cout<<"Y : "<<p1*d2-p2*d1/p1-p2<<endl;
    }

    system("PAUSE");
    return 0;
}
// 3.8 CORR Intervalle

#include <iostream>
using namespace std;

int main(){

 int a,b,c,d,tmp;

    cout<<"Entrez [a,b],[c,d]"<<endl;cin>>a;cin>>b;cin>>c;cin>>d;

    if(!((b>a)||(d>c))){ // CONDITION ERREUR
     //permutation
     if (a>c) {
        tmp=a;a=c;c=tmp;
        tmp=b;b=d;d=tmp;
     }
 
     if (c>b)
        cout<<"Intervale vide"<<endl;
     else {
      if (c==b)
         cout<<"Intervale ["<<c<<"]"<<endl;
      else if((c>=a)&&(d>b))
         cout<<"Intervale ["<<c<<","<<b<<"]"<<endl;
      else if ((c>=a)&&(d<=b)) 
         cout<<"Intervale ["<<c<<","<<d<<"]"<<endl;
     }
    }else{cout<<"erreur saisie"<<endl;}
    
    system("PAUSE");
    return 0;

}

Semaine 4 modifier

//3.6 Diviseurs
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int A,B;
    
    cout<<"Introduire A et B "<<endl;cin>>A;cin>>B;
    
    if (((double) (A%B)) ==0 ) cout<<A<<" est divisible par "<<B<<endl;
       else cout<<A<<" non divisible par "<<B<<endl;   
 
    system("PAUSE");
    return 0;
}
//3.7 Inclusion
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a,b,c,tmp;
    
    cout<<"Introduire A et B et C"<<endl;cin>>a;cin>>b;cin>>c;
    // permute A B
    if (a>b) {tmp=a;a=b;b=tmp;}
    if (c<a||c>b) cout<<c<<" non compris entre "<<a<<" et "<<b<<endl;
       else cout<<c<<" compris entre "<<a<<" et "<<b<<endl; 
 
    system("PAUSE");
    return 0;
}
// 3.8 Intervalle

#include <iostream>
using namespace std;

int main(){

 int a,b,c,d,tmp;

    cout<<"Entrez [a,b],[c,d]"<<endl;cin>>a;cin>>b;cin>>c;cin>>d;

    //permutation
    if (a>c) {

       tmp=a;a=c;c=tmp;
       tmp=b;b=d;d=tmp;

    }

    if (c>b)
       cout<<"Intervale vide"<<endl;
    else {
     if (c==b)
        cout<<"Intervale ["<<c<<"]"<<endl;
     else if((c>=a)&&(d>b))
        cout<<"Intervale ["<<c<<","<<b<<"]"<<endl;
     else if ((c>=a)&&(d<=b)) 
        cout<<"Intervale ["<<c<<","<<d<<"]"<<endl;
    }

    system("PAUSE");
    return 0;

}
//3.9 Nombre Impair
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a;
    
    cout<<"Introduire a"<<endl;cin>>a;

    if ((((double) (a%2)) != 0)&&a>82&&a<102) cout<<"PAS D'ERREUR"<<endl;
       else cout<<"ERREUR"<<endl; 
 
    system("PAUSE");
    return 0;
}

Semaine 5 modifier

//4.1 TEST borne
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a;
    
    while (a<56||a>78){
     cout<<"entrez un entier "<<endl;cin>>a;
     if (a<56||a>78) cout<<"perdu"<<endl;
    }
    
    cout<<"GAGNE"<<endl;   
 
    system("PAUSE");
    return 0;
}
//4.2 Entiers de 8 à 23
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a;
    
    for (a=8;a<24;a++)
     cout<<a<<endl;
 
    system("PAUSE");
    return 0;
}
//4.3 Entiers de 8 à 23
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a=8;
    
    while (a<24){
     cout<<a<<endl;a++;
    }
     
 
    system("PAUSE");
    return 0;
}
//4.4 Somme de 10 entiers
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a,nb,sum=0;
    
    for (a=0;a<10;a++){
     cout<<"entrez un entier "<<endl;cin>>nb;
     sum += nb;
    }
    
    cout<<"somme "<<sum<<endl;
     
 
    system("PAUSE");
    return 0;
}
//4.5 Min de 10 entiers
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a,nb,min=-1;
    
    for (a=0;a<10;a++){
     cout<<"entrez un entier "<<a+1<<endl;cin>>nb;
     if (min>nb||min<0) min = nb;
    }
    
    cout<<"Min "<<min<<endl;
     
 
    system("PAUSE");
    return 0;
}
//4.6 Somme des cubes

#include <iostream>
#include <cmath>
using namespace std;

int main(){

    int n,a;double sum=0;
    
    cout<<"Introduire un nombre"<<endl;cin>>n;

    for (a=5;a<=n;a++)
        sum += pow((double) a,3);

    cout<<"Somme des cubes = "<<sum<<endl;
    
    system("PAUSE");
    return EXIT_SUCCESS;

}
//4.7 Suite 1

#include <iostream>
#include <cmath>
using namespace std;

int main(){

    int n,a;double tot=3;

    cout<<"Introduire un nombre"<<endl;cin>>n;

    cout<<"u(0)="<<tot<<endl;
    for (a=1;a<=n;a++){
        tot=3*tot+4;
        cout<<"u("<<a<<")="<<tot<<endl;
    }

    system("PAUSE");
    return 0;

}
//4.8 Suite 2

#include <iostream>
#include <cmath>
using namespace std;

int main(){

    int n,c,a=1,b=1;double tot;
    cout<<"Introduire un nombre"<<endl;cin>>n;
    cout<<"u(0)="<<a<<endl;
    cout<<"u(1)="<<b<<endl;

    for (c=2;c<=n;c++){
        tot=a+b;a=b;b=tot;
        cout<<"u("<<a<<")="<<tot<<endl;
    }
    system("PAUSE");
    return 0;
}
//4.9 While

#include <iostream>
#include <cmath>
using namespace std;

int main(){

    int n;bool c=false;
    
    while(!c){
      cout<<"Introduire un nombre entre 1 et 20"<<endl;cin>>n;
      if (!(c=((n>=0)&&(n<=20)))) cout<<"Erreur"<<endl;
    }
    cout<<"Resultat : "<<n+17<<endl;

    system("PAUSE");
    return 0;

}
//4.10 Menu operations
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
 
    int a,res=0;
    
    cout<<"Nombre initial = "<<res<<endl;
    while (a!=4){
     cout<<"1. Ajouter 1"<<endl<<"2. Multiplier par 2"<<endl<<"3. Soustraire 4"<<endl<<"4. Quitter"<<endl;
     cin>>a;
     switch (a){
      
      case 1:res+=1;break;
      case 2:res*=2;break;
      case 3:res-=4;break;
      case 4:break;
      default: cout<<"Erreur"<<endl;break;
     }
     
     cout<<"Resultat = "<<res<<endl;
    }     
 
    system("PAUSE");
    return 0;
}
//4.5 CORRIGE / Min de 10 entiers
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
    int a,nb,min;
    
    cout<<"entrez 10 entiers"<<endl;
    cin>>nb;min=nb;    
    for (a=0;a<9;a++){
     cin>>nb;
     if (nb<min) min=nb;
    }
    
    cout<<"Min "<<min<<endl;

    system("PAUSE");
    return 0;
}

Semaine 6 modifier

// 4.11 Moyenne

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int x=1,sum=0,cpt=0;
    
    while (!(x==0)){

     if (x>0){
        cout<<"taper un entier"<<endl;cin>>x;
        sum += x;
        cpt++;
     }
     if(x<0) cout<<"Erreur"<<endl;
    }
    
    if (cpt==1) cout<<"Pas de moyenne"<<endl;
       else cout<<"Moyenne = "<<(double) sum/(cpt-1)<<endl;
    
    system("PAUSE");
    return 0;

}
// 4.12 Suite 3

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){
    
    int a=3,b=2,c,tmp, n=-1;
    
    while (n<0){
     cout<<"Entrez un entier "<<endl;cin>>n;
    }

    cout<<"u(0)="<<a<<endl;
    cout<<"u(1)="<<b<<endl;
    for (c=2;c<=n;c++){
     cout<<"u("<<c<<")="<<c*b+(c+1)*a+c<<endl;
     a=b;b=tmp;
    }

    system("PAUSE");
    return 0;
    
}
// 4.13 Nombre d'occurrences

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int a=0,b,tmp,cpt;
    for (b=0;b<10;b++){
     tmp=-1;

     while (tmp<0){

      cout<<"entrez un nombre "<<(b+1)<<endl;cin>>tmp;
      if(tmp>a) {a=tmp;cpt=1;}
       else if(tmp==a) {cpt++;}
      if (tmp<0) cout<<"Erreur !"<<endl;

     }
    }

    cout<<"le nombre d'occurrence de "<<a<<" = "<<cpt<<endl;

    system("PAUSE");
    return 0;

}
// 4.14 factorielle

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int n,cpt,fact=1;

    cout<<"entrer un entier "<<endl;cin>>n;

    for (cpt=2;cpt<=n;cpt++){
        fact *= cpt;
    }

    cout<<"fatorielle "<<n<<" = "<<fact<<endl;

    system("PAUSE");
    return 0;
}
// 4.15 Premier

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int n,cpt;bool ok=true;

    cout<<"entrer un entier "<<endl;cin>>n;
    cpt=2;
    while ((cpt<n)&&ok){
     if(((double) (n%cpt))==0) ok=false;
     cpt++;
    }

    if (ok) cout<<n<<" est premier"<<endl;
       else cout<<n<<" n'est pas premier"<<endl; 

    system("PAUSE");
    return 0;

}
// 4.16 # Premiers

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int n,cpt1=4,cpt2,tot=3;bool ok=true;

    cout<<"entrer un entier "<<endl;cin>>n;
    
    for (cpt1;cpt1<=n;cpt1++){
     cpt2=2;ok=true;
     while ((cpt2<cpt1)&&ok){
      if(((double) (cpt1%cpt2))==0) ok=false;
      cpt2++;
     }
     if (ok) tot++; 
    }

    cout<<tot<<" nombres premiers"<<endl;
    
    system("PAUSE");
    return 0;

}
// 4.17 # N-ieme Premier

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int n,cpt1=3,cpt2,tot=3;bool ok=true;

    cout<<"entrer un entier "<<endl;cin>>n;

    for(cpt1;tot<n;cpt1++){
     cpt2=2;ok=true;
     while ((cpt2<cpt1)&&ok){
      if(((double) (cpt1%cpt2))==0) ok=false;
      cpt2++;
     }
     if (ok) tot++;
    }

    cout<<tot<<"-ieme nombres premiers : "<<cpt1+1<<endl;

    system("PAUSE");
    return 0;

}
// 4.18 # Pyramide *

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int n,cpt1,cpt2;

    cout<<"entrer un entier "<<endl;cin>>n;

    for(cpt1=n;cpt1>0;cpt1--){
     for(cpt2=cpt1;cpt2>0;cpt2--){
      cout<<"*";
     }
     cout<<endl;
    }

    system("PAUSE");
    return 0;

}
// 4.19 # Pyramide2 *

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int n,cpt1,cpt2,cpt3;

    cout<<"entrer un entier "<<endl;cin>>n;

    for(cpt1=n;cpt1>0;cpt1--){
     for (cpt3=n-cpt1;cpt3>0;cpt3--)
      cout<<" ";             
     for(cpt2=cpt1;cpt2>0;cpt2--)
      cout<<"*";
     cout<<endl;
    }

    system("PAUSE");
    return 0;

}
// 4.20a Suite hongroise

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int a,tmp,cpt=0;

    cout<<"entrer un entier "<<endl;cin>>a;
    cout<<"u(0)="<<a<<endl;
    
    while(a!=1){
     cpt++;
     if (((double) (a%2)) == 0) a=a/2;
      else a=3*a+1;
     cout<<"u("<<cpt<<")="<<a<<endl;     
    }

    system("PAUSE");
    return 0;

}
// 4.20b Suite hongroise

#include <cstdlib>
#include <iostream>
using namespace std;

int main(){

    int M,N=2,A=2,a,cpt=2,cpt2;

    cout<<"entrer un entier "<<endl;cin>>M;

    for (cpt;cpt<=M;cpt++){

      cpt2=0;a=cpt;
      while(a != 1){
       cpt2++;
       if (((double) (a%2)) == 0) a=a/2;
        else a=3*a+1;
      }

      if(cpt2>N) {N=cpt2;A=cpt;}

    }

    cout<<"a(max) "<<A<<" en N "<<N<<endl;

    system("PAUSE");
    return 0;

}

Semaine 7 modifier

Zulul 15 mars 2006 à 21:11 (UTC)

// 6.1 TABLEAU > INT > 10
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
 
    int tab[10],nb=0,cpt;
    for(cpt=0;cpt<10;cpt++){
     cout<<cpt<<" ? "<<endl;cin>>tab[cpt];
    }
    for(cpt=0;cpt<10;cpt++)
     if(tab[cpt]>10)nb++;
 
    cout<<nb<<" ENTIERS > 10"<<endl;
    
    system("PAUSE");
    return 0;
}
// 6.2 RECHERCHE TAB

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
 
    int tab[10],V,cpt;
    for(cpt=0;cpt<10;cpt++){
     cout<<cpt<<" ? "<<endl;cin>>tab[cpt];
    }
    cout<<"V ? ";cin>>V;
    for(cpt=0;cpt<10&&V!=tab[cpt];cpt++);
    if(V==tab[cpt])cout<<"V Est dans tab"<<endl;
     else cout<<"V pas dans tab"<<endl;
    system("PAUSE");
    return 0;
}
// 6.3 RECHERCHE indice plus grand

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
 
    int tab[10],i,max=0,cpt;
    for(cpt=0;cpt<10;cpt++){
     cout<<cpt<<" ? ";cin>>tab[cpt];
    }
    for(cpt=0;cpt<10;cpt++)
     if(max<tab[cpt]){
      max=tab[cpt];
      i=cpt;
     }
    cout<<"plus grand : "<<i<<endl;
    system("PAUSE");
    return 0;
}
// 6.4 decalage gauche

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
 
    int tab[10],V,flag=0,cpt;
    for(cpt=0;cpt<10;cpt++){
     cout<<cpt<<" ? ";cin>>tab[cpt];
    }
    cout<<"V ? ";cin>>V;
    for(cpt=0;cpt<10;cpt++){
     if(tab[cpt]==V&&!flag)flag=1;
     if(flag&&cpt!=9)tab[cpt]=tab[cpt+1];
     if(cpt==9)tab[cpt]=0;
     }

    for(cpt=0;cpt<10;cpt++)
     cout<<tab[cpt]<<"  ";

    system("PAUSE");
    return 0;
}
// 6.5 insert, decalage droite

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
 
    int tab[10],V,tmp,i=-1,flag=0,cpt;
    for(cpt=0;cpt<10;cpt++){
     cout<<cpt<<" ? ";cin>>tab[cpt];
    }
    cout<<"V ? ";cin>>V;
    
    while(i<0||i>9){cout<<"i ? ";cin>>i;}
     
    for(cpt=0;cpt<10;cpt++){
     if(flag){V=tab[cpt];tab[cpt]=tmp;tmp=V;}
     if(cpt==i){flag=1;tmp=tab[cpt];tab[cpt]=V;}
    }

    for(cpt=0;cpt<10;cpt++)
     cout<<tab[cpt]<<"  ";

    system("PAUSE");
    return 0;
}

Semaine 8 modifier

Zulul 1 mai 2006 à 15:49 (UTC)

// 66 tableau
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {

    int v[10], i, cmpneg, cmppos;
    bool neg=1, pos=1;

    for(i=0; i<10; ++i) {
     cout<<"nombre "<<i+1<<" ";cin>>v[i];
    }

    for(i=0; i<9; ++i) {
     if(v[i]>v[i+1]){pos=0;}
     if(v[i]<v[i+1]){neg=0;}
    }

    if(pos&&!neg){cout<<"tableau croissant"<<endl;}
    if(!pos&&neg){cout<<"tableau decroissant"<<endl;}
    if(pos&&neg){cout<<"tableau constant"<<endl;}
    if(!pos&&!neg){cout<<"tableau quelconque"<<endl;}

    system("PAUSE");
    return 0;

}
//67 TRI TABLEAU
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {

    int v[10], i, j, tmp, idx;

    for(i=0; i<10; ++i) {
     cout<<"nombre "<<i+1<<" ";cin>>v[i];
    }

    //tri
    for(i=0; i<10;++i) {
      idx=i+1;
      for(j=i+1;j<10;++j) {
       if(v[j]<v[idx]){idx=j;}             
      }
      if(v[idx]<v[i]){tmp=v[idx];v[idx]=v[i];v[i]=tmp;};
    }

    //AFFICHAGE
    for(i=0; i<10;++i) {
      cout<<i<<" - "<<v[i]<<" / ";
    }

    system("PAUSE");
    return 0;

}
//68 TRI BULLE TABLEAU
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {

    int v[10], i, j, tmp, cpt=-1;

    for(i=0; i<10; ++i) {
     cout<<"nombre "<<i+1<<" ";cin>>v[i];
    }

    //tri bulle
    while(cpt!=0) {
      cpt=0;
      for(i=0;i<10;++i) {
       if(v[i+1]<v[i]){tmp=v[i];v[i]=v[i+1];v[i+1]=tmp;cpt++;}             
      }
    }

    //AFFICHAGE
    for(i=0; i<10;++i) {
      cout<<i<<" - "<<v[i]<<" / ";
    }

    system("PAUSE");
    return 0;

}
//69 FUSION TABLEAUX
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {

    int a[10], b[10], c[20], i;

    cout<<"remplir les vecteurs a et b"<<endl;
    for(i=0; i<10; ++i) {
     cout<<"a "<<i+1<<" ";cin>>a[i];
     cout<<"b "<<i+1<<" ";cin>>b[i];     
    }

    //fusion
    for(i=0;i<10;++i){
     c[i]=a[i];c[19-i]=b[9-i];            
    }
    
    //AFFICHAGE
    for(i=0; i<20;++i) {
      cout<<"c["<<i<<"] : "<<c[i]<<" / ";
    }

    system("PAUSE");
    return 0;

}
//6.10 TRI+FUSION+TRI TABLEAUX
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[]) {

    int a[10], b[10], c[20], i=0, j=0, tmp, cpt=1;
    bool tri=1, ok=0;

    cout<<"remplir les vecteurs a et b"<<endl;
    for(i=0; i<10; ++i) {
     cout<<"a "<<i+1<<" ";cin>>a[i];
     cout<<"b "<<i+1<<" ";cin>>b[i];
     if(i>0&&a[i]<a[i-1]||b[i]<b[i-1]){tri=0;}
    }

    //check tri
    while(!ok) {
     if(tri&&b[9]>a[9]) { 
      for(i=0;i<10;++i) { //fusion
       c[i]=a[i];c[19-i]=b[9-i];            
      }                        
      ok=1;
     } else { //tri bulle
      while(cpt!=0){
       cpt=0;
       for(i=0;i<9;++i) {
        if(a[i+1]<a[i]){tmp=a[i];a[i]=a[i+1];a[i+1]=tmp;cpt++;}
        if(b[i+1]<b[i]){tmp=b[i];b[i]=b[i+1];b[i+1]=tmp;cpt++;}        
       }
      }
      i=0;
      while(i+j<18){
       //cout<<"a["<<i<<"]"<<a[i]<<" - b["<<j<<"]"<<b[j]<<endl;
       if(a[i]<=b[j]){c[i+j]=a[i];i++;}else{c[i+j]=b[j];j++;}
      }
      ok=1;
     }
    }

    //AFFICHAGE C
    for(i=0; i<20;++i) {
      cout<<"c["<<i<<"] : "<<c[i]<<" / ";
    }

    system("PAUSE");
    return 0;

}

++ WIKI DS 1 / DEBUTE A - Zulul 1 mai 2006 à 17:34 (UTC)

Edité en notepad sans compilation
#include <cstdlib>
#include <iostream>
using namespace std;

int main(){
	
	int a,b,v[10],i,cpt=0,tmp;
	
	cout<<"a ? ";cin>>a;cout<<"b ? ";cin>>b;
	if(a>b){tmp=a;a=b;b=tmp;} //swap
	
	for(i=0;i<10;i++){
	 cout<<"v["<<i<<"] ";cin>>v[i];
	}
	//compteur
	for(i=0;i<10;i++){
	 if(v[i]>=a&&v[i]<=b){cpt++;}
	}
	
	if(cpt<2){
	 cout<<cpt<<" occurrence";
	}else{
	 cout<<cpt<<" occurrences";
	}
	cout<<" entre a "<<a<<" et b "<<b<<endl;
	
	return 0;
}
#include <cstdlib>
#include <iostream>
using namespace std;

int main(){
	
	int N, i=0, u=1;
	
	cout<<"N ? ";cin>>N;
	
	cout<<"u("<<i<<") "<<u<<endl;
	for(i=1;i<N+1;i++){
	 u=2*u+i-1;
	 cout<<"u("<<i<<") "<<u;
	}

	return 0;
}
#include <cstdlib>
#include <iostream>
using namespace std;

int main(){
	
	int v[10],i,idx;
	
	for(i=0;i<10;i++){
	 cout<<"v["<<i<<"] ";cin>>v[i];
	}
	//verif
	idx=9;
	for(i=8;i>=0;--i){
	 if(v[i]>=v[idx]){idx=i;}
	}
	
	cout<<"premier indice du plus grand est "<<idx<<endl;
	
	return 0;
	
}
#include <cstdlib>
#include <iostream>
using namespace std;

int main(){
	
	int N,i,j,k;
	
	cout<<"N ? ";cin>>N;
	
	for(i=0;i<N+1;i++){
	 cout<<"N="<<i+1<<endl;
	 for(j=0;j<i+1;j++){
	  for(k=0;k<j+2;k++)cout<<"A";
	  for(k=j+1;k<i+1;k++)cout<<"B";
	  cout<<endl;
	 }
	}	
	return 0;
}
#include <cstdlib>
#include <iostream>
using namespace std;

int main(){
	
	int v[10],i, idx=0, A, c=0, moy=0, num=-1;
	bool ko=1;

	while(c!=5){
	cout<<"1. ajout"<<endl<<"2. liste"<<endl<<"3. moyenne"<<endl<<"4. supprimer"<<endl<<"5. quitter"<<endl;
	
	switch(c){
		case 1:
			while(ko){
			 ko=0;
			 cout<<"A ? ";cin>>A;v[idx]=A;idx++;break;
			 for(i=0;i<idx+1;i++) if(A==v[i]){ko=1;cout<<"existe deja!"<<endl;}
			}
		case 2:
			for(i=0;i<idx+1;++i){cout<<"v["<<i<<"] : "<<v[i]<<endl;}
		case 3:
			for(i=0;i<idx+1;++i){moy += moy+v[i];}
			cout<<"moyenne : "<<(double) moy/(idx+1)<<endl;
		case 4:
			while(num<0||num>idx){cout<<"indice a supprimer ? ";cin>>num;}
			for(i=num;i<idx+1;i++){v[i]=v[i+1];}
			--idx;
		default:
			cout<<"choix incorrect"<<endl;break;
	}
	return 0;
}

++ TERMINE A - Zulul 1 mai 2006 à 18:27 (UTC)

Semaine 9 modifier

  • Zulul 1 mai 2006 à 19:28 (UTC)
// 9.1 hypothenuse
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

double hypo(double xa, double ya, double xb, double yb ) {
    
    return (sqrt(pow(xb-xa,2)+pow(yb-ya,2)));
    
}

int main(int argc, char *argv[]) {
    
    double ax, ay, bx, by;
    
    cout<<"entrez ax, ay ";cin>>ax;cin>>ay;
    cout<<"entrez bx, by ";cin>>bx;cin>>by;
    
    cout<<"DISTANCE AB : "<<hypo(ax, ay, bx, by)<<endl;
 
    system("pause");
    return 0;   
}
// 9.2 sqrt((x-1)*(2-x))
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

double f(double x, bool &ok ) {
    
    if(x>=1&&x<=2){return sqrt((x-1)*(2-x));ok=1;}else{ok=0;}
    
}

int main(int argc, char *argv[]) {
    
    double x, res;bool ok;
    
    cout<<"entrez x";cin>>x;
    
    res=f(x,ok);
    if(ok){cout<<"RAC (x-1)*(2-x) : "<<res<<endl;}else{cout<<"x incorrect"<<endl;}
 
    system("pause");
    return 0;   
}
// 9.3 premier
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

bool f(int x) {
    
    bool ok=1;int i;
    
    if(i>2){
     for(i=2;i<x;i++){if(!((double) (x%i)))ok=0;}
    }
    return ok;
    
}

int main(int argc, char *argv[]) {
    
    int x=0;
    
    while(x<=0) {cout<<"entrez x";cin>>x;}
    
    if(f(x)) cout<<x<<" est premier"<<endl; 
    else cout<<x<<" est non premier"<<endl;
 
    system("pause");
    return 0;   
}
// 9.4 nieme premier
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

bool f(int x) {
    
    bool ok=1;int i;
    
    if(i>2){
     for(i=2;i<x;i++){if(!((double) (x%i)))ok=0;}
    }
    return ok;
    
}

int main(int argc, char *argv[]) {
    
    int x=0, cpt1=0, cpt2=0;
    
    while(x<=0) {cout<<"entrez x";cin>>x;}
    
    while(cpt1<x){ 
     cpt2++;
     if(f(cpt2)) {cpt1++;cout<<cpt2<<" premier"<<endl;}
    }
    
    cout<<x<<"ieme premier : "<<cpt2<<endl;
 
    system("pause");
    return 0;   
}
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

void swap(int &a, int &b) {
    
    int tmp;
    
    tmp=a;a=b;b=tmp;
       
}

int main(int argc, char *argv[]) {
    
    int a, b;
    
    cout<<"a ? ";cin>>a;
    cout<<"b ? ";cin>>b;
    
    cout<<"avant a:"<<a<<" b:"<<b<<endl;
    swap(a,b);
    cout<<"apres a:"<<a<<" b:"<<b<<endl;
    
    system("pause");
    return 0;   
}

Semaine 10 modifier

//9.6 CHECK [0-10] VECTEUR

#include <cstdlib>
#include <iostream>

using namespace std;

bool check (int t[], int n) {
     
     int i;bool ok=0;
     
     for(i=0;i<=n;++i)
      if(t[i]<=10&&t[i]>0) ok=1;
      
     return ok;         
         
}

int main(int argc, char *argv[]) {
    
    bool ok;int t[20], n, i;
    
    cout<<"intro des valeurs"<<endl;
    for(i=0;i<20;++i) {
                      
     cout<<"t["<<i<<"] "<<endl;cin>>t[i];
     
    }
    
    cout<<"intro de n ? "<<endl;cin>>n;
    
    if(check(t,n))
     cout<<"t contient un chiffre avant "<<n<<endl;
    else
     cout<<"t ne contient pas de chiffre avant "<<n<<endl;   
    
    system("PAUSE");
    return 0;

}
//9.7 compte [0-10] VECTEUR

#include <cstdlib>
#include <iostream>

using namespace std;

int check (int t[], int n) {
     
     int i, cpt=0;bool ok=0;
     
     for(i=0;i<=n;++i)
      if(t[i]<=10&&t[i]>0) cpt++;
      
     return cpt;         
         
}

int main(int argc, char *argv[]) {
    
    bool ok;int t[20], n, i;
    
    cout<<"intro des valeurs"<<endl;
    for(i=0;i<20;++i) {
                      
     cout<<"t["<<i<<"] "<<endl;cin>>t[i];
     
    }
    
    cout<<"intro de n ? "<<endl;cin>>n;
    
    cout<<"t[] contient "<<check(t,n)<<" chiffres de 0 à "<<n<<endl;
    
    system("PAUSE");
    return 0;

}
//9.8 check [0-10] VECTEUR > indice pos 1

#include <cstdlib>
#include <iostream>

using namespace std;

bool check (int t[], int n, int & v) {
     
     int i, cpt=0;bool ok=0;

     for(i=n;i>=0;--i)
      if(t[i]<=10&&t[i]>0) { ok=1;v=i;}
      
     return ok;         
   
}

int main(int argc, char *argv[]) {
    
    bool ok;int t[20], n, i, v;
    
    cout<<"intro des valeurs"<<endl;
    for(i=0;i<20;++i) {
                      
     cout<<"t["<<i<<"] "<<endl;cin>>t[i];
     
    }
    
    cout<<"intro de n ? "<<endl;cin>>n;
  
    if(check(t,n,v)) 
      cout<<"t[] contient chiffre de 0 à "<<n<<", Premier position :"<<v<<endl;

    system("PAUSE");
    return 0;
}
//9.9 check [0-10] V1 > V2

#include <cstdlib>
#include <iostream>

using namespace std;

int place (int t1[], int * t2, int n) {
     
     int i, a=0, cpt=0;bool ok=0;
     
     for(i=n;i>=0;--i) if(t1[i]<=10&&t1[i]>0) { cpt++;t2[a]=t1[i];a++;}
      
     return cpt;         
         
}

int main(int argc, char *argv[]) {
    
    bool ok;int t1[20], t2[20], n, i, v;
    
    cout<<"intro des valeurs"<<endl;
    for(i=0;i<20;++i) {
                      
     cout<<"t1["<<i<<"] "<<endl;cin>>t1[i];
    
    }
    
    cout<<"intro de n ? "<<endl;cin>>n;
    
    v=place(t1,t2,n);
    
    if(v>0) cout<<"t1[] contient "<<v<<" [0_10]"<<endl;

    i=0;
    for(i=0;i<v;i++)
     cout<<i<<" "<<t2[i]<<endl;
    
    system("PAUSE");
    return 0;

}
//10 check [0-10] V1

#include <cstdlib>
#include <iostream>

using namespace std;

int f(int t1[], int n) {
     
     int i, a=0, cpt=0;bool ok=0;
     for(i=n;i>=0;--i) if(t1[i]<=10&&t1[i]>0) { ok=1;a=i;}
     if(!ok) a=-1;
     
     return a;

}

int main(int argc, char *argv[]) {
    
    bool ok;int t1[20], n, i, v;
    cout<<"intro des valeurs"<<endl;
    for(i=0;i<20;++i) {cout<<"t1["<<i<<"] "<<endl;cin>>t1[i];}
    cout<<"intro de n ? "<<endl;cin>>n;
    
    v=f(t1,n);
    
    if(v!=-1) cout<<"t1[] contient [0-10] en pos : "<<v<<endl;
    else cout<<"t1[] ne contient pas de [0-10] avant "<<n<<endl;
    
    system("PAUSE");return 0;

}

Semaine 11 modifier

//8.1 chk if nbr

#include <cstdlib>
#include <iostream>

using namespace std;

bool chk(char t[], int & e) {

     int i=0; bool r=1;
     if ((t[i]-'0')<1||(t[i]-'0')>9) { r=0; }
     while(t[i]!='\0'&&r)
       if((t[i]-'0')<0||(t[i]-'0')>9) { r=0; }else{ e=(e*10)+(t[i++]-'0'); }

     return r;
     
}

int main(int argc, char *argv[]) {
    
    char t[10]; int e=0;
    
    cout<<"introduire un nombre"<<endl;cin>>t;
    
    if(chk(t,e))
     cout<<e<<" est un nombre"<<endl;
    else
     cout<<t<<" n'est pas un nombre"<<endl;
    
    system("PAUSE");
    return 0;

}
//8.2 min->maj

#include <cstdlib>
#include <iostream>

using namespace std;

void maj(char *t) {

     int i=0;
     while(t[i]!='\0'){
       if(t[i]>96&&t[i]<123) { t[i]=t[i]-32; }
       i++;
     }
}

int main(int argc, char *argv[]) {

    char t[30];

    cout<<"introduire une petite phrase"<<endl;cin.getline(t,30);

    cout<<"avant :"<<t<<endl;
    maj(t);
    cout<<"apres :"<<t<<endl;

    system("PAUSE");
    return 0;

}
//8.3 suppression voyelle

#include <cstdlib>
#include <iostream>

using namespace std;

void sup_voy(char *t) {

     int i=0,j,k; char v[13];bool ok;
     strcpy(v,"aeiouyAEIOUY");
     
     while(t[i]!='\0') {
       ok=0;
       for(j=0;j<12;j++)
        if(t[i]==v[j]) {
          t[i]=t[i+1];k=i+1;ok=1;
          while(t[k]!='\0') {t[k]=t[k+1];k++;}
        }
       (!ok)?i++:0;
     }
}

int main(int argc, char *argv[]) {

    char t[30];
   
    cout<<"introduire une petite phrase"<<endl;cin.getline(t,30);

    cout<<"avant :"<<t<<endl;
    sup_voy(t);
    cout<<"apres :"<<t<<endl;

    system("PAUSE");
    return 0;

}
//8.4 ch2 dans ch1

#include <cstdlib>
#include <iostream>

using namespace std;

bool cmp_str(char ch1[], char ch2[]) {

     int i,j;bool ok=0;
     
     for(i=0;i<(strlen(ch1)-strlen(ch2)+1);i++) {
        j=0;
        if(ch1[i]==ch2[j]) {
          ok=1;
          while(j<strlen(ch2)&&ok) {ch1[i+j]==ch2[j++]?ok:ok=0;}
        }
     }
     return ok;
}

int main(int argc, char *argv[]) {

    char ch1[20], ch2[10];

    cout<<"introduire une ch1"<<endl;cin.getline(ch1,20);
    cout<<"introduire une ch2"<<endl;cin.getline(ch2,10);    
    
    if(cmp_str(ch1,ch2)) cout<<ch1<<endl<<"contient"<<endl<<ch2<<endl;
    else cout<<ch2<<" non compris dans "<<ch1<<endl;

    system("PAUSE");
    return 0;

}
//8.5 verbe 1er groupe

#include <cstdlib>
#include <iostream>

using namespace std;

bool cnj(char ch[]) {

     bool ok=0;
     (strlen(ch)<3||ch[strlen(ch)-1]!='r'||ch[strlen(ch)-2]!='e')?ok=0:ok=1;
     
     if(ok){
      ch[strlen(ch)-2]='\0';    
      cout<<"je "<<ch<<"e"<<endl;
      cout<<"tu "<<ch<<"es"<<endl;
      cout<<"il "<<ch<<"e"<<endl;  
      cout<<"nous "<<ch<<"ons"<<endl;
      cout<<"vous "<<ch<<"ez"<<endl;
      cout<<"ils "<<ch<<"ent"<<endl; 
     }                   
     return ok;
}

int main(int argc, char *argv[]) {

    char ch[20];

    cout<<"introduire un verbe du premier groupe"<<endl;cin>>ch;
    if(!cnj(ch))cout<<ch<<" pas du premier groupe"<<endl;

    system("PAUSE");
    return 0;

}
//8.6 split str

#include <cstdlib>
#include <iostream>

using namespace std;

void split(char ch[]) {

     int i,j=0;
     char tmp[20];

     for(i=0;i<=strlen(ch);++i) {
     
       if(ch[i]==' '||ch[i]=='\0') {
         tmp[j]='\0';
         cout<<tmp<<endl;
         j=0;
       }else { tmp[j]=ch[i];j++;}
             
     }
}

int main(int argc, char *argv[]) {

    char ch[30];

    cout<<"introduire une phrase"<<endl;cin.getline(ch,30);
    split(ch);
    
    system("PAUSE");
    return 0;

}
//8.7 palindrome

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {

    char ch[15];int i;bool ok=1;

    cout<<"introduire une chaine"<<endl;cin>>ch;

    for(i=0;i<=(strlen(ch)/2)&&ok;++i)
     (ch[i]==ch[(strlen(ch)-1)-i])?ok:ok=0;
    
    if(ok) cout<<ch<<" est un palindrome"<<endl;
    else cout<<ch<<" n'est pas un palindrome"<<endl; 
    
    system("PAUSE");
    return 0;

}
//8.8 #car plus courrant

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {

    char ch[30];int i=0, j=0, cpt, max; char c;

    cout<<"introduire une phrase"<<endl;cin.getline(ch,30);

    c=ch[i];max=1;
    while(ch[i]!='\0') {
     for(j=0, cpt=0;j<strlen(ch);++j){
      (ch[j]==ch[i])?cpt++:cpt;
     }
     if(cpt>max){max=cpt;c=ch[i];}
     ++i;                   
    }
    
    cout<<"max "<<c<<" avec "<<max<<" occurences"<<endl; 
    
    system("PAUSE");
    return 0;

}

Semaine 12 modifier

//9.1 calcule (A+B)/(D-E*F) 
//-------------------------
#include <cstdlib>
#include <iostream>

using namespace std;

struct FRACTION {
 int a, b;
};

int PGCD(int a, int b) {
    return ((a%b==0)?b:PGCD(b,a%b));
}
    
bool NORMALIZE(int &a, int &b, bool chk=0) {
     
     bool ok=true;int pgcd=0;
     
     (chk)?ok:((b<1)?ok=0:ok);
     
     pgcd=PGCD(a,b);
     if(pgcd) {
      a/=pgcd;b/=pgcd;
     }
     return ok;
}
     
void SAISIR(FRACTION &x) {
     
     bool ok=0;
     
     while(!ok) {
      cout<<"numerateur : ";cin>>x.a;
      cout<<"denominateur : ";cin>>x.b;
      ok=NORMALIZE(x.a,x.b);
     }

}

void AFFICHE(FRACTION x) {

     cout<<x.a<<"/"<<x.b<<endl;

}
     
FRACTION SOMME(FRACTION x1, FRACTION x2) {

     FRACTION x;
     x.a=x1.a*x2.b+x2.a*x1.b;
     x.b=x1.b*x2.b;
     NORMALIZE(x.a,x.b);
     return x;

}
     
FRACTION DIFFERENCE(FRACTION x1, FRACTION x2) {

     FRACTION x;
     x.a=x1.a*x2.b-x2.a*x1.b;
     x.b=x1.b*x2.b;
     NORMALIZE(x.a,x.b);
     return x;
     
}
     
FRACTION DIVISE(FRACTION x1, FRACTION x2) {

     FRACTION x;
     x.a=x1.a*x2.b;
     x.b=x1.b*x2.a;
     NORMALIZE(x.a,x.b);
     return x;
}
     
FRACTION MULTIPLIE(FRACTION x1, FRACTION x2) {

     FRACTION x;
     x.a=x1.a*x2.a;
     x.b=x1.b*x2.b;
     NORMALIZE(x.a,x.b);
     return x;

}
     
int main(int argc, char *argv[]) {

     FRACTION A,B,D,E,F,RES;

     cout<<"A ?"<<endl;SAISIR(A);
     cout<<"B ?"<<endl;SAISIR(B);
     cout<<"D ?"<<endl;SAISIR(D);
     cout<<"E ?"<<endl;SAISIR(E);
     cout<<"F ?"<<endl;SAISIR(F);
     
     cout<<"(A+B)/(D-E*F)"<<endl;
     RES=DIVISE(SOMME(A,B),DIFFERENCE(D,MULTIPLIE(E,F)));
     NORMALIZE(RES.a,RES.b,1);
     AFFICHE(RES);

     system("PAUSE");
     return 0;

}

Semaine 13 modifier

// 9.2 - Gestion de listes d'articles
//-----------------------------------

//PRD.h - Scope produit-----------
#ifndef PRD_M
#define PRD_M

struct PRD{
  
 char ref[9];
 char den[99];
 int qte;
    
};

void saisir_prd(PRD &e,char ref[]);
void aff_prd(PRD e);

#endif
//--------------------------------

//PRD.cpp - Fonctions produits----
#include "menu.h" 
#include<iostream>
#include <cstdlib>

using namespace std;

void saisir_prd(PRD &e,char ref[]) {

 if(strlen(ref)<3)
  while(strlen(ref)<3){cout<<"Reference ? ";cin>>ref;}
 else
  strcpy(e.ref,ref);
 
 strcpy(e.ref,ref);
 cout<<"Tapez la denomination : ";cin>>e.den;
 e.qte=0;

}

void aff_prd(PRD e) {
 cout<<e.ref<<" "<<e.den<<" "<<e.qte<<endl;
}
//--------------------------------

//LST.h - Scope liste-------------

#ifndef LST_M
#define LST_M
#include "PRD.h"

const int lst_max=100;

struct LST {
 int nb;
 PRD lst_prd[lst_max];
};

LST init_lst();
bool add(LST &l);
bool sup(LST &l);
int ach(LST &l);
int ven(LST &l1,LST &l2);
void aff(LST l);

#endif
//--------------------------------

//LST.cpp - Fonctions listes------

#include "LST.h"
#include <iostream>
#include <cstring>

using namespace std;

LST init_lst() {
    
    LST lst;lst.nb=0;
    return lst;
    
}

bool add(LST &l) {

    bool ok=0,ko=0;char ref[9];int i;

    cout<<"nb avant : "<<l.nb<<endl;
    if(l.nb<=lst_max) {
     
     while(!ok) {

      cout<<"reference produit ? "<<endl;cin>>ref;
      for(i=0;i<(l.nb-1)&&(strcmp(l.lst_prd[i].ref,ref));i++);
      
      if(strcmp(l.lst_prd[i].ref,ref)) {
       saisir_prd(l.lst_prd[l.nb],ref);
       ok=1;l.nb++;
       cout<<"nb apres : "<<l.nb<<endl;       
      } else {
       cout<<ref<<" deja present"<<endl;
      }
      
     }
    } else {
      ko=1;
    }
    
    return ko;
    
}

bool sup(LST &l) {

    char ref[9];int i;bool ok=0;

    while(!ok) {
    cout<<"Produit a supprimer : "<<endl;cin>>ref;
    for(i=0;(strcmp(l.lst_prd[i].ref,ref)!=0&&(i<l.nb));++i);
    if(strcmp(l.lst_prd[i].ref,ref)==0) {
      cout<<"sup "<<l.lst_prd[i].ref<<" - "<<ref<<endl;
      ok=1;
      for(i;i<l.nb;++i)
       l.lst_prd[i]=l.lst_prd[i+1];
      l.nb--;
     }
    }

    return ok;

}

int ach(LST &l) {

    int qte,i; char ref[9];bool ok=0;
    while(!ok) {
     cout<<"Produit ? Quantite ?"<<endl;cin>>ref;cin>>qte;
     for(i=0;(strcmp(l.lst_prd[i].ref,ref)!=0&&(i<l.nb));++i);
     if(strcmp(l.lst_prd[i].ref,ref)==0){
      l.lst_prd[i].qte+=qte;
      ok=1;
     }
    }

    return qte;

}

int chk(LST l,char ref[]){

 int pos=-1,i;
 
 for(i=0;(strcmp(l.lst_prd[i].ref,ref)!=0&&(i<l.nb));++i);
 if(strcmp(l.lst_prd[i].ref,ref)==0) pos=i;
 
 return pos;
     
}

int ven(LST &l1,LST &l2) {

    int qte,i,a; char ref[9];
    cout<<"Produit ? Quantite ?"<<endl;cin>>ref;cin>>qte;
    for(i=0;(strcmp(l1.lst_prd[i].ref,ref)!=0&&(i<l1.nb));++i);
    if((strcmp(l1.lst_prd[i].ref,ref)==0)&&(l1.lst_prd[i].qte>0)) {
     if(l1.lst_prd[i].qte-qte>-1) {
      
      l1.lst_prd[i].qte-=qte;
      (a=chk(l2,ref))!=101?a:a=l2.nb++;
      strcpy(l2.lst_prd[a].ref,l1.lst_prd[i].ref);
      l2.lst_prd[a].qte=((int)(qte));
      
     }else{
           
      (a=chk(l2,ref))!=101?a:a=l2.nb++;
      qte=l2.lst_prd[a].qte=l1.lst_prd[i].qte;
      l1.lst_prd[i].qte=0;
      cout<<ref<<" stock epuisé"<<endl;qte=0;
      
     }
    }else{
     cout<<ref<<" stock epuisé"<<endl;qte=0;
    }

    return qte;

}

void aff(LST l) {

    cout<<"LISTE DES PRODUITS-------------------------------------------"<<endl;
    for(int i=0;i<l.nb;++i)
     aff_prd(l.lst_prd[i]);

}
//--------------------------------

//MENU.h - Scope menu-------------
#ifndef MENU_H
#define MENU_H
#include "LST.h"

void menu(LST &l, LST &l2);
int chx();

bool exe_chx(LST &art, LST &cad, int chx);

#endif
//--------------------------------

//MENU.CPP - GESTION DES ARTICLES-
#include "menu.h" 
#include<iostream>
#include<ctype.h>

using namespace std;

int chx() {

 char i;
 
 cout<<"1. Ajouter un produit"<<endl;
 cout<<"2. Afficher les produits."<<endl;
 cout<<"3. Supprimer un produit"<<endl;
 cout<<"4. Acheter les produits"<<endl;
 cout<<"5. Vendre un produit"<<endl;
 cout<<"6. Quitter"<<endl;
 
 while(!(isdigit(i))||(i-48<1)||(i-48>6)){
  cout<<"Votre choix : ";cin>>i;
 }
 
 return ((int)(i-48));

}

void menu(LST &l1, LST &l2) {

 bool ok=0;
 int i;
 
 do {
    i=chx();
    ok=exe_chx(l1,l2,i);
 }while(!ok);

}

bool exe_chx(LST &art, LST &cad, int chx) {

 bool ok=0;

 cout<<"art : "<<art.nb<<endl;
 switch(chx) {

    case 1:
     if(add(art)) cout<<"La liste est pleine"<<endl;break;
    case 2:
     aff(art);break;
    case 3:
     sup(art);break;
    case 4:
     ach(art);break;
    case 5:
     ven(art,cad);break;
    case 6:
     ok=1;break;

 }

 return ok;

} 
//--------------------------------

//main.cpp Appli------------------
#include <cstdlib>
#include <iostream>
#include "MENU.h";

using namespace std;

int main(int argc, char *argv[]) {

    LST article, caddy;
    
    article=init_lst();
    caddy=init_lst();
    menu(article, caddy);
    
    system("PAUSE");
    return 0;

}
//--------------------------------
// 9.3 - Gestion de listes de disques
//-----------------------------------

// disque.h
//-----------------------------------------------
#ifndef disque_M
#define disque_M

struct disque{
  
  char ref[9];
  char nomChanteur[99];
  char nomChanson[99];
  double prix;
    
};

void saisir_disque(disque &e,char ref[]);
void aff_disque(disque e);

#endif
//-----------------------------------------------

// disque.cpp
//-----------------------------------------------

#include "disque.h"
#include<iostream>
#include <cstdlib>

using namespace std;

void saisir_disque(disque &e,char ref[])
{//

 if(strlen(ref)<3)
    while(strlen(ref)<3){cout<<"Reference ? ";cin>>ref;}
 else
    strcpy(e.ref,ref);

    cout<<"Tapez le nomChanteur : ";cin>>e.nomChanteur;
    cout<<"Tapez le nomChanson : ";cin>>e.nomChanson;
    cout<<"Tapez le prix : ";cin>>e.prix;

}//

void aff_disque(disque e)
{//
   cout<<e.ref<<" "<<e.nomChanteur<<" "<<e.nomChanson<<" "<<e.prix<<"€"<<endl;
}//
//-----------------------------------------------

// lst.h
//-----------------------------------------------
#ifndef lst_M
#define lst_M
#include "disque.h"

const int lst_max=100;

struct lst {
 int nb;
 disque lst_disque[lst_max];
};

lst init_lst();
bool add(lst &l);
bool sup(lst &l);
int ach(lst &l);
int ven(lst &l1,lst &l2);
void aff(lst l);
//-----------------------------------------------

// lst.cpp
//-----------------------------------------------
#include "lst.h"
#include <iostream>
#include <cstring>

using namespace std;

lst init_lst()
{
    lst lst;lst.nb=0;
    return lst;
}

bool add(lst &l)
{
    bool ok=0,ko=0;char ref[9];int i;
    
    cout<<"nb avant : "<<l.nb<<endl;
    if(l.nb<=lst_max)
    {
        while(!ok)
        {
          cout<<"reference disque ? "<<endl;cin>>ref;
          for(i=0;i<(l.nb-1)&&(strcmp(l.lst_disque[i].ref,ref));i++);
          
          if(strcmp(l.lst_disque[i].ref,ref))
          {
            saisir_disque(l.lst_disque[l.nb],ref);
            ok=1;l.nb++;
            cout<<"nb apres : "<<l.nb<<endl;       
          }
          else
          {
            cout<<ref<<" deja present"<<endl;
          }
       }
    }
    else
    {
       ko=1;
    }
    
return ko;    
}

bool lstChanteur(lst &l)
{
    bool ok=0,ko=0;char nomChanteur[99];int i;
    
    if(l.nb<=lst_max)
    {
        while(!ok)
        {
          cout<<"nomChanteur disque ? "<<endl;cin>>nomChanteur;
                    
          if(strcmp(l.lst_disque[i].nomChanteur,nomChanteur))
          {
            aff_disque(l.lst_disque[i]);
            l.nb++;
          }
       }
    }
    else
    {
       ko=1;
    }
    
return ko;
}

bool lstTitre(lst &l)
{
    bool ok=0,ko=0;char titre[99];int i;
    
    if(l.nb<=lst_max)
    {
        while(!ok)
        {
          cout<<"titre disque ? "<<endl;cin>>titre;
                    
          if(strcmp(l.lst_disque[i].titre,titre))
          {
            aff_disque(l.lst_disque[i]);
            l.nb++;
          }
       }
    }
    else
    {
       ko=1;
    }
    
return ko;
}

bool sup(lst &l) {

    char ref[9];int i;bool ok=0;

    while(!ok)
    {
        cout<<"Disque a supprimer : "<<endl;cin>>ref;
        for(i=0;(strcmp(l.lst_disque[i].ref,ref)!=0 && (i<l.nb));++i);
        if(strcmp(l.lst_disque[i].ref,ref)==0)
        {
          cout<<"sup "<<l.lst_disque[i].ref<<" - "<<ref<<endl;
          ok=1;
          for(i;i<l.nb;++i)
            l.lst_disque[i]=l.lst_disque[i+1];
          l.nb--;
        }
    }
return ok;
}

int chk(lst l,char ref[])
{
    int pos=-1,i;
 
    for(i=0;(strcmp(l.lst_disque[i].ref,ref)!=0 &&(i<l.nb));++i);
    if(strcmp(l.lst_disque[i].ref,ref)==0) pos=i;
 
return pos;   
}

void aff(lst l)
{

    cout<<"LISTE DES DISQUES-------------------------------------------"<<endl;
    for(int i=0;i<l.nb;++i)
     aff_disque(l.lst_disque[i]);

}
//-----------------------------------------------

// menu.h
//-----------------------------------------------
#ifndef MENU_H
#define MENU_H
#include "lst.h"

void menu(lst &l, lst &l2);
int chx();

bool exe_chx(lst &art, lst &cad, int chx);

//-----------------------------------------------

// menu.cpp
//-----------------------------------------------
//MENU.CPP - GESTION DES ARTICLES-
#include "menu.h" 
#include<iostream>
#include<ctype.h>

using namespace std;

int chx()
{

 char i;
 
 cout<<"1. Ajouter un disque à la liste"<<endl;
 cout<<"2. Afficher la liste"<<endl;
 cout<<"3. Supprimer un disque grâce à son code référence"<<endl;
 cout<<"4. Afficher tous les disques d'un chanteur donné"<<endl;
 cout<<"5. Afficher tous les disques ayant un titre donné"<<endl;
 cout<<"6. Quitter"<<endl;
 
 while(!(isdigit(i))||(i-48<1)||(i-48>6)){
  cout<<"Votre choix : ";cin>>i;
 }
 
return ((int)(i-48));
}

void menu(lst &l1, LST &l2)
{
    bool ok=0;
    int i;
    
    do {
    i=chx();
    ok=exe_chx(l1,l2,i);
    }while(!ok);
}

bool exe_chx(lst &art, int chx)
{
  bool ok=0;

  cout<<"art : "<<art.nb<<endl;
  switch(chx)
  {
    case 1:
     if(add(art)) cout<<"La liste est pleine"<<endl;break;
    case 2:
     aff(art);break;
    case 3:
     sup(art);break;
    case 4:
     lstChanteur(art);break;
    case 5:
     lstTitre(art);break;
    case 6:
     ok=1;break;
  }

return ok;
} 
//-----------------------------------------------

//main.cpp Appli
//-----------------------------------------------
#include <cstdlib>
#include <iostream>
#include "MENU.h";

using namespace std;

int main(int argc, char *argv[]) {

    lst article, caddy;
    
    article=init_lst();
    caddy=init_lst();
    menu(article, caddy);
    
    system("PAUSE");
    return 0;

}
//-----------------------------------------------

Semaine 14 modifier

Semaine 15 modifier

Appréciations du wikiprof modifier

Semaine 1 modifier

Bon travail. A priori tu utilises dev-cpp sous windows (non ?) Merrheim 8 février 2006 à 14:21 (UTC)

Oui tout a fait, c'est ce compilateur.

Semaine 2 modifier

  • 2.1)

Une petite erreur : le type int est utilisé pour représenter un entier. Pour représenter la longueur d'un champs on utilisera plutôt le type double. Il faut également afficher le périmètre du champs. Merrheim 8 février 2006 à 14:57 (UTC)
Pour le 2.1 lo et la doivent être de type double Merrheim 8 février 2006 à 18:47 (UTC)

  • 2.2) petite erreur : avec le programme proposé la moyenne de 10, 10, 10, 10 et 11 est de 10 ! En réalité elle est de 10.2. Bien faire attention aux types des varaibles. Il faut se poser la question : quelle est la nuature des données que le programme manipule ? entier ou réel ?
Ok merci, je vais revenir dessus. - Zulul 8 février 2006 à 15:19 (UTC)
Ok pour la correction du 2.2

Vous pouvez écrire directement b=b+a avec b double et a int ==> Le compilateur transformera fera automatiquement le cast.

  • 2.3 OK RAS
  • 2.4 OK RAS
  • 2.5 un détail préférer #include<cmath> à #include<math.h>

BON travail et bonne continuation Merrheim 8 février 2006 à 18:56 (UTC)

Semaine 3 modifier

  • 3.1. a et b sont de type double. Les 3 cas sont

a nul et b nul ==> tiout x est solution
a nul b non nul ==> pas de solutions a non nul==> solution unique

Je vais modifier...Zulul 14 février 2006 à 10:29 (UTC)
  • 3.2 L'algo ne marche pas si tous les entiers sont négatifs.

Il faut remplacer le premier if (a>b) b=a; par b=a;

Je vais modifier...Zulul 14 février 2006 à 10:29 (UTC)
  • 3.3 OK
  • 3.4 des petits soucis car si les droitres sont verticales vos formules mathématiques ne marchent pas. Il semble que ce soit plus un pb de math que d'info.
Je vais modifier...Zulul 14 février 2006 à 10:29 (UTC)
La division par zero posait probleme, je prendrai plus de temps pour tester à l'avenir. / Zulul 4 avril 2006 à 15:35 (UTC)
  • 3.5 OK au lieu d'écrire x-2*x vous pouvez écrire -x tout simplement.

Semaine 4 modifier

  • 3.6 OK mais attention le module s'effecture sans cast au lieu d'écrire (((double) (A%B)) ==0 écrivez tout simplement (A%B) ==0
  • 3.7 OK
  • 3.8 votre algo ne marche pas dans tous les cas. testez vos programmes de nombreuses fois.
Je vais modifier...Zulul 14 février 2006 à 10:29 (UTC)
J'ai testés tous les cas à mon avis et mis a part une condition supplémentaire en cas de b>a ou d>c je ne prevois rien d'autre... j'ai encore omis quelque chose ? Zulul 4 avril 2006 à 16:54 (UTC)
  • 3.9 même remarque sur le modulo

Conclusion : vous avez compris les algos mais parfois vous n'avez pas testé tous les cas de figure et vous avez quelques petits soucis d'ordre mathématique.

En effet, je crois qu'une revision en math ne serait pas de trop.

Semaine 5 modifier

  • 4.1 OK
  • 4.2 OK
  • 4.3 OK
  • 4.4 OK
  • 4.5 OK l'algo ne marche pas si vous n'avez que des entiers négatifs
Je vais modifier...Zulul 14 février 2006 à 10:30 (UTC)
Comme ça c'est ok Zulul 4 avril 2006 à 17:14 (UTC)

Semaine 6 modifier

Semaine 7 modifier

Semaine 8 modifier

Semaine 9 modifier

Semaine 10 modifier

Semaine 11 modifier

Semaine 12 modifier

Semaine 13 modifier

Semaine 14 modifier

Semaine 15 modifier

Avis du wikitudiant sur le wikimodule modifier

Semaine 1 modifier

Semaine 2 modifier

Semaine 3 modifier

Vous n'avez pas mis d'exemple utilisant un else if() dans ce chapitre.

Semaine 4 modifier

Je ne suis pas familier des suites numeriques et arithmetiques. Ce serait utile de mettre des liens vers des wikibooks de math appliqués à l'informatique :)

Semaine 5 modifier

Semaine 6 modifier

Semaine 7 modifier

Les premiers exercices proposés dans ce chapitre ne me semblent pas trop représentatifs des cas d'utilisation des tableaux.
De plus, l'ecriture des fonction(params) n'a pas encore ete abordée.

==> erreur de chapitre de ma part c'est corrigé maintenant désolé Merrheim 14 février 2006 à 10:00 (UTC)

Semaine 8 modifier

Après l'etude de vos chapitre et la suite d'exercices réalisés jusque là, j'ai tout de même dû tricher un petit peu pour me souvenir des fichiers à inclure ainsi que du namespace à utiliser. Zulul 1 mai 2006 à 18:32 (UTC)

Semaine 9 modifier

  • On est vite tenté de s'inspirer des solutions je trouve... ça démange trop ! Zulul 1 mai 2006 à 19:47 (UTC)

Semaine 10 modifier

Semaine 11 modifier

Semaine 12 modifier

Semaine 13 modifier

Semaine 14 modifier

Semaine 15 modifier

Les wikinotes obtenues pour ce module modifier

Obtention du wikimodule modifier

Ce module est actuellement : NON OBTENU