Cod sursa(job #406324)

Utilizator AndreiRSStatescu Andrei Rares AndreiRS Data 1 martie 2010 13:58:30
Problema Tablete Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <stdio.h>

int n,k,i,j,nr,x;

int main(){
	
	FILE*f1=fopen("tablete.in","r");	
	fscanf(f1,"%d %d",&n,&k);
	fclose(f1);	
	
	FILE*f2=fopen("tablete.out","w");
	for(i=1,nr=1;i<=n;i++){
		for(j=1;j<=n;j++,nr++)
			if(j==k && nr%2==1){
				fprintf(f2,"%d ",nr+1);
				fprintf(f2,"%d ",nr);
				j++;
				nr++;
				}
			else
				fprintf(f2,"%d ",nr);
		fprintf(f2,"\n");
	}
	fclose(f2);
	
	return 0;
}