darkthunder | voilà jai fait ce petit programme et mon compilateur m'indique les erreurs suivantes:
--------------------Configuration: 3 - Win32 Debug--------------------
Compiling...
5.cpp
E:\26042003bis\3\5.cpp(45) : error C2601: 'main' : local function definitions are illegal
E:\26042003bis\3\5.cpp(76) : error C2958: the left parenthesis '(' found at 'E:\26042003bis\3\5.cpp(49)' was not matched correctly
E:\26042003bis\3\5.cpp(81) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
3.exe - 3 error(s), 0 warning(s)
Code :
- #include<stdio.h>
- int tab[4][3];
- int nand (int a,int b){
- if (a==0||b==0)return 1;
- else return 0;
- }
- int and (int a, int b){
- if(a==0||b==0)return 0;
- else return 1;
- }
- int or(int a, int b){
- if (a==1||b==1)return 1;
- else return 0;
- }
- int nor(int a, int b){
- if (a==1||b==1)return 0;
- else return 1;
- }
- void tab_bin(void){
- tab[0][0]=0;
- tab[0][1]=0;
- tab[1][0]=0;
- tab[1][1]=1;
- tab[2][0]=1;
- tab[2][1]=0;
- tab[3][0]=1;
- tab[3][1]=1;}
- void affichage (){ int j;
- printf("| A | B | Q |\n" );
- printf("-------------------\n" );
- for (j=0;j<4;j++)
- {printf("| |\n" );
- printf("| %d | %d | %d |\n",tab[j][0],tab[j][1],tab[j][2]);
- printf("-------------------\n" );}
- int main (){
- int j,rep;
- printf(("1.NAND\n2.AND\n3.OR\n4.NOR\n" );
- scanf("%d",&rep);
- switch(rep){
- case'1':for (j=0;j<4;j++)
- tab[j][2]= nand(tab[j][0],tab[j][1]);
- affichage();break;
- case'2':
- for (j=0;j<4;j++)
- tab[j][2]= and(tab[j][0],tab[j][1]);
- affichage();break;
- case'3':
- for (j=0;j<4;j++)
- tab[j][2]= or(tab[j][0],tab[j][1]);
- affichage();break;
- case'4':
- for (j=0;j<4;j++)
- tab[j][2]= nor(tab[j][0],tab[j][1]);
- affichage();break;
- }
- return (0);
- }
|
|