검색결과 리스트
2015/06에 해당되는 글 4건
- 2015.06.19 print start recursive c example
- 2015.06.19 zigzag c exmaple
- 2015.06.19 fraction sort c example
- 2015.06.19 shortest path c example
#include <stdio.h>
void printStar(int n)
{
while(n>0)
{
printf("*");
n--;
}
printf("\n");
}
void star(int n, int i)
{
if (n==0)
return;
printStar(i);
star(n-1, i+1);
if (n!=1)
printStar(i);
}
int main()
{
int n;
scanf("%d", &n);
star(n, 1);
return 0;
}
STL set set_intersection example (0) | 2015.12.03 |
---|---|
freopen example (0) | 2015.11.30 |
print start recursive c example (0) | 2015.06.19 |
zigzag c exmaple (0) | 2015.06.19 |
fraction sort c example (0) | 2015.06.19 |
shortest path c example (0) | 2015.06.19 |
#include <stdio.h>
int matrix[201][201];
int count=1;
void fillCount(int x, int y)
{
if(x != 0) //오른쪽 위로 진행
{
while(x>=0 && y>=0)
{
if (matrix[x][y] ==1)
matrix[x][y] = count++;
x--;
y++;
}
}
else //왼쪽 아래로 진행
{
while(x>=0 && y>=0)
{
if (matrix[x][y] ==1)
matrix[x][y] = count++;
x++;
y--;
}
}
}
int main()
{
int n, i, j;
int num;
scanf("%d", &n);
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
matrix[i][j] = 1;
}
}
for(num=0; num < (2*n)-1; num++)
{
if(num%2 == 0)
{
fillCount(0,num);
}
else
{
fillCount(num,0);
}
}
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
printf("%d ",matrix[i][j]);
}
printf("\n");
}
return 0;
}
freopen example (0) | 2015.11.30 |
---|---|
print start recursive c example (0) | 2015.06.19 |
zigzag c exmaple (0) | 2015.06.19 |
fraction sort c example (0) | 2015.06.19 |
shortest path c example (0) | 2015.06.19 |
generate all combination of elements using 2-dimension vector (0) | 2015.04.30 |
#include <stdio.h>
#include <stdlib.h>
typedef struct Entry{
int denominator; //분모
int numerator; //분자
struct Entry* next;
}ENTRY;
ENTRY head;
void deleteLink()
{
ENTRY *go, *target;
go = head.next;
while(go)
{
target = go;
go = go->next;
free(target);
}
}
void printLink()
{
ENTRY *go;
for(go = head.next; go != NULL; go=go->next)
{
printf("%d/%d\n", go->numerator, go->denominator);
}
}
void insert(ENTRY* temp)
{
ENTRY *go, *pre;
pre = &head;
for(go = head.next; go != NULL; pre=go, go=go->next)
{
// puts("111");
if((float)temp->numerator/temp->denominator <= (float)go->numerator/go->denominator)
break;
}
if(go != NULL) //중간에 나옴
{
// puts("222");
if ((float)temp->numerator/temp->denominator == (float)go->numerator/go->denominator)
return;
else
{
go = (ENTRY *)malloc(sizeof(ENTRY));
go->denominator = temp->denominator;
go->numerator = temp->numerator;
go->next = pre->next;
pre->next = go;
}
}
else //끝까지 봄
{
// puts("333");
go = (ENTRY *)malloc(sizeof(ENTRY));
go->denominator = temp->denominator;
go->numerator = temp->numerator;
go->next = pre->next;
pre->next = go;
}
}
void main()
{
int n;
int denominator; //분모
int numerator; //분자
ENTRY temp;
// n입력
scanf("%d", &n);
//예외처리
if (n < 1 || n > 160)
return;
// printf("%d", n);
for(denominator = 1; denominator <= n; denominator++)
{
for(numerator = 0; numerator <= denominator; numerator++)
{
temp.denominator = denominator;
temp.numerator = numerator;
insert(&temp);
// printLink();
// getchar();
}
}
printLink();
deleteLink();
}
print start recursive c example (0) | 2015.06.19 |
---|---|
zigzag c exmaple (0) | 2015.06.19 |
fraction sort c example (0) | 2015.06.19 |
shortest path c example (0) | 2015.06.19 |
generate all combination of elements using 2-dimension vector (0) | 2015.04.30 |
list example C++ (0) | 2014.11.06 |
#include<stdio.h>
#include<stdlib.h>
#define MAX 10
int map[MAX][MAX];
int min_sum;
int min_city;
void find_Allpath(int current_where, int max, int sum, int city_cnt, int maxsum)
{
int i, zero_cnt = 0;
if (city_cnt > max-1)
{
return;
}
if (current_where == max - 1)
{
if (min_sum == 0)
{
min_sum = sum;
}
else
{
if (min_sum > sum)
{
min_sum = sum;
min_city = city_cnt;
}
}
return;
}
for (i = 0; i < max; i++)
{
if (map[current_where][i] == 0)
{
zero_cnt++;
}
if (zero_cnt == max)
{
return;
}
}
for (i = 0; i < max; i++)
{
if (map[current_where][i] != 0)
{
find_Allpath(i, max, sum + map[current_where][i], city_cnt+1, maxsum);
}
}
}
int main(void)
{
int n, i, j, max_sum=0;
freopen("T.txt", "r", stdin);
scanf("%d", &n);
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
scanf("%d", &map[i][j]);
max_sum += map[i][j];
}
}
find_Allpath(0, n, 0, 0, max_sum);
printf("%d\n", min_sum);
return 0;
}
zigzag c exmaple (0) | 2015.06.19 |
---|---|
fraction sort c example (0) | 2015.06.19 |
shortest path c example (0) | 2015.06.19 |
generate all combination of elements using 2-dimension vector (0) | 2015.04.30 |
list example C++ (0) | 2014.11.06 |
access() 파일 존재 여부 (0) | 2014.10.30 |
RECENT COMMENT