Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Calendar Loops

DZone's Guide to

Calendar Loops

·
Free Resource
this program is very usefull when you need to know the list of dates of a repetitive task in the week.

I create this program to fill the records of my teaches in a school.


#include 
  
   


int meses[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dias[365][3];
/*
0 Lunes
1 Martes
2 Miercoles
3 Jueves
4 Viernes
5 Sabado
6 Domingo
*/

int cursos[7][4]={{0,0,0,0},{2,2,0,0},{1,0,1,1},{0,1,0,0},{0,0,2,2},{0,0,0,0},{0,0,0,0}};

int main(){
    int i,j,k;
    dias[0][0]=5;
    for (i=1;i<365;i++){
        dias[i][0]=(dias[i-1][0]+1)%7;                       
    }    
    k=0;
    for (i=0;i<12;i++){
        for (j=1;j<=meses[i];j++){
            dias[k][1]=i;    
            dias[k][2]=j;
            k++;
        }
    }
    
    for (i=0;i<365;i++){
       // bool salto=false;
        for (j=0;j<4;j++){

            for (k=0;k
   
  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}