Programing Calendar

Hi and happy cristhams

I am programing a calendar to much time but i cant realize that the compiler can translate these, i dont know i am making bad, i put the code and the dev c++ compile errors catched :
[code.]

#include <stdio.h>

int algoritmozeller (int anno, int mes, int i ) {

int w,y,h;



if(mes<=2) {
mes = mes + 12;
anno = anno - 1;
}

else {
mes = mes - 2;
}

y = anno % 100;
w = anno / 100;

h = (( 700 + (( 26 * mes - 2)/10) + i + y + (y/4) + (w/4) + 5 * w) % 7);

return (h);

}



void calendariodibujo(int primerdia, int n, int k) {

if(primerdia == 1) {

k = 1;
printf(" %d",k );
for(int i = 2; i<= 7; i++) {


if(i < 7) {







printf(" %d",i);

}

if(i == 7) {

printf("%d\n", i);


}
}


for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}


if( primerdia == 2) {

k = 1;



printf(" %d", k);


for(int i = 3; i <= 7; i++) {



if(i < 7) {







printf(" %d",i);

}

if(i == 7) {

printf("%d\n", i);


}
}


for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}
}

if(primerdia == 3) {


printf(" %d",k);

for(int i = 4; i <= 7; i++) {

if(i < 7) {







printf(" %d",i);

}

if(i == 7) {

printf("%d\n", i);


}
}


for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}

}

if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}







if(primerdia == 4) {

k = 1;


printf(" %d", k);




for(int i = 3; i <= 7; i++) {



if(i < 7) {







printf(" %d",i);

}

if(i == 7) {

printf("%d\n", i);


}


for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}


if(primerdia == 5){


printf(" %d", k);


for(int i = 6; i <= 7; i++) {


if(i < 7) {







printf(" %d",i);

}

if(i == 7) {

printf("%d\n", i);


}
}


for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}




if(primerdia == 6) {


printf(" %d",k);

for(int i = 7; i <= 7; i++) {
if(i < 7) {







printf(" %d",i);

}

if(i == 7) {

printf("%d\n", i);


}
}


for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}


if(primerdia == 7) {


k = 1;


printf(" %d\n ",k);











for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}







for(int i = 8; i <= 14; i++) {

printf(" %d", i);


if(i == 14) {

printf(" %d\n", i);


}

}








for(int i = 15; i <= 21; i++) {

if(i != 21) {


printf(" %d",i);

}
if(i == 21) {

printf(" %d\n", i);

}

}


for(int i = 21; i <= 28 ; i++) {

if(i != 28) {

printf(" %d",i);

}

if(i == 28) {

printf(" %d\n", i);

}



if( n != 0) {

for( int i = 29; i <= 28 + n; i++) {

if(i != 29 + n) {

printf(" %d", i );



}

if( i == 28 + n) {

printf(" %d\n", i);

}


}

}

}

}

}

}



[/code.]
Last edited on

int main() {

int anno, mes, i , primerdia;







printf("Escriba el número del año del que desee calcular el calendario");
scanf("%d", anno);

printf("Escriba el número de mes del año anteriormente escrito");
scanf("%d", mes);


if(anno > 1601 && anno < 3000) {

if (mes == 1) {
printf( " Enero");

n = 3;
}
if (mes == 2){
printf( " Febrero");

if(bisiesto) {

n = 1;

}

if(anno != bisiesto) {


n = 0;
}

}
if (mes == 3){
printf("Marzo");

n = 3;
}
if (mes == 4){
printf("Abril");

n = 2;
}
if (mes == 5){
printf("Mayo");

n = 3;
}
if (mes == 6) {
printf("Junio");

n = 2;
}

if (mes == 7) {
printf("Julio");

n = 3;
}
if (mes == 8) {
printf("Agosto");

n = 3;
}
if (mes == 9) {
printf("Septiembre");

n = 2;
}
if (mes == 10) {
printf("Octubre");

n = 3;
}

if (mes == 11) {
printf("Noviembre");

n = 2;
}
if (mes == 12){
printf("Diciembre");

n = 3;

}

printf(" %d\n", anno);
printf(" \n");

printf("===========================\n");

printf("LU MA MI JU VI | SA DO\n");

printf("===========================\n");





i = 1;

primerdia = algoritmozeller(anno, mes, i);




calendariodibujo(primerdia, k, n);

}

Line 1005 expected `}' at end of input (x 4 veces)

expected `}' at end of input

expected `;' before "int"

expected primary-expression before "int"


closed account (j3Rz8vqX)
Excluding the period(.)

You should edit your post and add "[code.]" in before and "[/code.]" after your code. It would make it more readable; without the period.

This would solve your posting of indentation, line reference, and possibly make it easier for folks to debug.
Last edited on
closed account (j3Rz8vqX)
Dude, that is an ugly output, embed it within the source code tag.

As for your error, I've actually debugged it.

Add 5 more '}' before your main.

That will eliminate most of your faulty errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...\main.cpp||In function 'int main()':|
...
...\main.cpp|758|warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat]|
...
...\main.cpp|761|warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat]|
...\main.cpp|769|error: 'n' was not declared in this scope|
...\main.cpp|774|error: 'bisiesto' was not declared in this scope|
...\main.cpp|776|error: 'n' was not declared in this scope|
...\main.cpp|780|error: 'bisiesto' was not declared in this scope|
...\main.cpp|783|error: 'n' was not declared in this scope|
...\main.cpp|790|error: 'n' was not declared in this scope|
...\main.cpp|795|error: 'n' was not declared in this scope|
...\main.cpp|800|error: 'n' was not declared in this scope|
...\main.cpp|805|error: 'n' was not declared in this scope|
...\main.cpp|811|error: 'n' was not declared in this scope|
...\main.cpp|816|error: 'n' was not declared in this scope|
...\main.cpp|821|error: 'n' was not declared in this scope|
...\main.cpp|825|error: 'n' was not declared in this scope|
...\main.cpp|829|error: 'n' was not declared in this scope|
...\main.cpp|833|error: 'n' was not declared in this scope|
...\main.cpp|842|error: 'k' was not declared in this scope|
...\main.cpp|842|error: 'n' was not declared in this scope|
||=== Build finished: 17 errors, 2 warnings (0 minutes, 0 seconds) ===|


Your error lines won't match, because I attempted to clean up your 1004 lines of code for 15 minutes before conceding.

May have been the websites posting format at fault, but you really ought to learn how to properly post code on this site if you plan to use it.

Add to your main function:
 
int n,k;


Add '}' to the end of your main loop.

And I have no idea how your bisiesto variable is suppose to behave but it's apparently a bool or (int/char)condition of some sort.

I'm not diving into it anymore than this.
Last edited on
your code is not easy to read.....
make it simple .. you can use functions in it to make it smaller.... or just test it once before going in 2nd step....
Topic archived. No new replies allowed.