U E D R , A S I H C RSS

새싹교실/2012/주먹밥


1.


06
12
12
12

2.

3/21 3/28 4/3,4 4/5 4/11 4/16
O O O O O O
O O O X O X
O O X O X O
O O X O X O

3.

  • : 기 결과 3개 . 그고 C . 그 +@

  • : + , , 게 기.
  • : 기 c , .
  • : .

4.2. 1(2012/3/21)




  • Linux GCC
  • Wiki
  • (?)

4.2.1.


  • : . , . , . 그고 wiwki , . 그 Virtual Box . Hello World . 그 . .
  • : "" . . 3 고 wiki . . 그 . . 그 . .. . .

  • : (208-216) 과, , 3 21 PM6 gcc, Linux, android example, wiki . .

  • :, , . . 꼭 걸 . , 그 . . 2 .

4.3. 2(2012/3/28)


4.3.2.


  • 간 : 6 PC 6

    /2012//2
    /2011//4

  • 2

  • 기 게 Linux gedit .

    • -

  • . ? , . 고.

  • -> C . .


  • printf(), scanf() ?


  • int, char, float, long, double . , , . ?


  • #define . #define ? 그 .


  • . math.h . time.h .srand(time(NULL)) .

  • if, switch()case: default:}, for, while . . switch case break :(

  • ACM

4.3.3.


  • -


#include<stdio.h>
int main() {

int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);

if(a>b) {
	d=b;
	b=a;
	a=d;
}
if(b>c) {
	d=c;
	c=b;
	b=d;
}
if(a>b) {
	d=b;
	b=a;
	a=d;
}
printf("%d %d %d",a,b,c);

return 0;

}

  • -


#include <stdio.h>

int main(void)
{
	int num;

	printf("Input integer.");
	scanf("%d", &num);

	if(num % 400 == 0)
		printf("Leap");
	else if((num % 4 == 0) || (num & 100 != 0))
		printf("Leap");
	else
		printf("Normal");

	return 0;
}

  • -


#include<stdio.h>
int main()
{
	int a,b,c;
	int d;

	scanf("%d %d %d",&a,&b,&c);

	if(a>b)
	{	
		d=b;
		b=a;
		a=d;
	}
	if(b>c)
	{	d=c;
		c=b;
		b=d;
	}
	if(a>b)
	{
		d=b;
		b=a;
		a=d;
	}
	
	if(a==b || a==c || b==c )
	{
		printf("Impossible");
	}
	else printf("%d %d %d",a,b,c);

	return 0;
}		

4.3.4. 2

  • -

#include<stdio.h>
int main(void)
{
	unsigned int y;
	scanf("%u",&y);
	if(y%400==0) {
		printf("Leap\n");
		return 0;
	}
	if(y%100==0) {
		printf("Normal\n");
		return 0;
	}
	if(y%4==0){
		printf("Leap\n");
        }
        printf("Normal\n");
	return 0;
}





  • -

#include<stdio.h>

int main()
{
 long long n;
 bool t = 0; 

 scanf("%lld",&n);
 
 if(n%4==0)
 {
  t = 1;
  if(n%100 == 0)
  {
   t = 0;
   if(n%400 == 0)
   { 
    t = 1; 
   }     
  }
 }
 if(t)
 { 
  printf("Leap");
 }
 else
 {
  printf("Normal");
 }
 return 0;
}

4.4. 3(4/3, 4/4 )


  • 기 Ice Breaking

4.4.1. ICE breaking


  • - 게. . 1 . . map editor거 굉 . . . C . 교 . . 고 고기 . .

  • - 과 . . 고 고. MT . . 그 . 과. 기계 그거 고. . . 기. . *^^*

  • - . 그 . 그 . . . . 24 10 . ~ 그 거 4 =ㅂ= !!!! 4 고 갔. . !

4.4.3.1. (2012/4/3, 4/4)

  • - C 고급. . . . int , char , float . ? . 0과 1 ?

  • if

   int a = 5;
   if(a >3){
      printf("a 3 .\n");
   }
   else printf(" 고.\n");
  • for

   for(1,2,4){
       3;
   }

   for(i = 0;i<5;i++){
   }

  • while

    a = 5;
    while(a>3){
        a--;
    }
    printf("%d",a);


  • +-*/% ||&& != == <= >= ~^&| ++i i++
    • +-*/%
    • || && : || &&
    • != == <= >= :
    • ~^&| : char 1byte -> 8bit ~ 0과 1 ^ & 1 1 | 1 1 .
    • ()
    • ++i i++ i = i +1;과 결과 .

  • : .
  • 곳 : int 4byte 공간 고 그 값(address) .
  • : 32bit 4byte 64bit 8byte . (void *), (int *), (float *) . int *a 4byte 고 a 값(address) . (*) . int까 4byte ?
  • C Call-by-value . .
  • Call-by-value, Call-by-reference


#include<stdio.h>

void swap(int a, int b){
   int temp;
   temp = a;
   a = b;
   b = temp;
}

void swap2(int *a, int *b){
   int temp;
   temp = *a;
   *a = *b;
   *b = *temp;
}

int main(){
   int i=3,j=5;

   swap(i,j);
   printf("%d %d\n",i,j);
   swap2(&i,&j);
   printf("%d %d\n",i,j);
   return 0;
}

  • Call-by-reference . !
  • 기(naming). !
  • (array) int a[10]; a int 10개 고 0~9까 (index) .
    • a . scanf("%d",a); a[0] .
    • a[2] *(a+2)

  • typedef
    • !
    • typedef typedef ; .

///typedef 
typedef struct _CALORIE{
	char name[40];
	float value;
}CALORIE;

CALORIE myfood;

  CALORIE   

  • - 구 Call-by-value Call-by-reference 기게 .

 valuefunc(myfood);
 referencefunc(&myfood);


    • .

CALORIE a;
CALORIE *b = &a;

scanf("%s, %f",a.name,&(a.value)); //a.name 과 a.value   !    .
printf("%s %.2f\n",a.name,a.value); //그 기
printf("%s %.2f\n",b->name,b->value); //-> 



///pcal  40개     .
///num   .
float calcalc(CALORIE *pcal, int num){
	char name[40];
	float gram = 0;
	float totalcal = 0.0;
	int i;
	printf("--   -------------\n");
	for(i = 0; i<num;i++) //갯 
		printf("%s\t", (pcal+i)->name); //. 
	printf("\n----------------------------------------\n");
	while(1){
		printf("(end .) : ");
		scanf("%s", name);
		if(strcmp(name, "end") == 0)
			break;
		printf("그  : ");
		scanf("%f", & gram);
		for(i=0;i<num;i++){
			if(strcmp(name, (pcal+i)->name) == 0){
				totalcal += (pcal+i)->value * gram /100.0;
				break;
			}
		}
	}
	return totalcal;
}	

4.4.3.2. (2012/4/8)




  • - .
  • ?

#include<stdio.h>

int func(){
   return 0;
}

int main(){
   printf("%d\n",func(1,2,3,4)); 
   return 0;
}


4.4.3.3.


4.5. 4(2012/4/11)

4.5.1.



  • ( )
    • . *(:Pointer) FILE 구 . (File) C FILE 구 . 그 * FILE구 . Good Good!
    • . , , 기, . http://winapi.co.kr/clec/cpp2/17-2-1.htm .
    • . '' . C:\\Desktop\test.txt . ? C:\\Desktop\\test.txt txt ? ? . 그 ? 그 . .\test.txt test 고. ..\test.txt . ? .\\test.txt . .
    • .
    • stdin, stout. . fprintf print .

#include <stdio.h>

int main(){
   int a;
   fprintf(stdout,"%d",5);
   printf("%d",5);
   fscanf(stdin,"%d",&a);
   scanf("%d",&a);

   return 0;
}


  • > . test.exe 5
    CMD test.txt

 test.exe > test.txt
test.txt 5 .


  • Git Repository 고 Readme 기.

4.5.2. ,


  • .
  • .
  • iOS개 . 경 .
    • ? -
  • .
    • Scroll %
    • (x/값) * 100 . int 0 . 그 (float)(x/값) * 100 .

4.6. 5(2012/4/18)

 

4.6.1. ,


  • : -> . .
    • : . 갈길 . . 善! () () . () (善) . 기. 그 기게 ( ). . . Just do it! . . . . Whatever! . .

  • : -> OOP ?
    • : 객 (Object Oriented Programming). 계 기. 계 기 . API . 그 Class . 객 C++ Java Class Class . 그... . . C Class . . 그게 .

  • : , -> ?
    • : 1 . 1 ? ? . 금 C . 고 간 .

  • : , -> ?
    • : Windows API 30 ? . javascript alert(5)? ? ~~ ?



  • SVN

    • for for for . 그 .
    • if 0 0 . 공!

4.7. 5 23


  • 기! 거.

4.7.1.



<html>
<head>
<script language = "javascript">

left = 10;

function key(){
	var image=document.getElementById("demo");
	image.style.position="absolute";
	
	alert(left);
	left += 1;
	image.style.left = left; //  left   . left   .
	//image.style.left=(left+1)+'px';
	//var l=document.getElementById("demo").style.left += 1;
	
}
	
</script>

</head>

<body onKeyDown='key();'>

<img src = "1.jpg" id="demo" top = 10 left = 10>


</body>
</html>

4.7.2.


  • javascript

4.7.3. 궁금




4.8. 5 24




4.8.1.


 <-> Objective - C?

고

  -> 

	-    고.

	-  Web View .

C공 .

 -> Opensource 

    

 ->    .  .

 궁금거

Sort .

	- Bubble Sort
	- Quick Sort .   고
		->  .
#include<algorithm.h>

quicksort( );



<html>
<body>

<script type="text/javascript">
	document.write("<p>My first paragraph</p>");
</script>
</body>
</html>

4.8.2.


4.9. 5 31


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void main() {
	int i,j,Input;
	int temp;
	int count = 0;
	int a[10] = {0,};
	srand(time(NULL));
	printf("\n");
	
	/*
	for(i=0;i<10;i++) { //  10개  
		a[i] = rand()%10+1;
		printf("%3d", a[i]);
	}
	*/
	do{
		temp = rand()%10+1;
		for(i = 0;i<10;i++){
			if(a[i] == temp){
				temp = rand()%10+1;
				i = -1;
			}
		}

		a[count++] = temp;

	}while(count != 10);
	for(i = 0;i<10;i++)
		printf("%d ",a[i]);


	
	puts("\n---------------------------------");


	/*
	for(i=0;i<10;i++)
	{
		for(j=0;j<9;j++)
		{
			if(a[j]>a[j+1])
			{
				temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
			}
		}
	}
	*/
	/*
	for(i=0;i<10;i++)
	{
		for(j=i+1;j<10;j++)
		{
			if(a[i]>a[j])
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	} 
	*/

	for(i=0;i<10;i++) { // 결과 
		printf("%3d", a[i]);
	}
	puts("");
	
}
  • : APM 깔기, (, ) 5개 기.


#include<stdio.h>

int factorial(int n){
	if(n == 1) return 1;
	return n * factorial(n-1);
}

int summary(int n){
	if(n == 1) return 1;
	return n + summary(n-1);
}


int main(){
	
	int i,j,sum = 0, fact =1;
	int input = 5;

	for(i = 1; i <= input;i++){
		sum += i;
		fact *= i;
	}

	printf("sum : %d, fact : %d\n",sum,fact);

	sum = 0 ; fact =1;

	fact = factorial(input);
	sum = summary(input);

	printf("sum : %d, fact : %d\n",sum,fact);

	

	return 0;
}
  • : 기.

4.10. 6 1


  • Part


<html>
<head>
<script language = "javascript">

left = 10;
imagename = 1;

function key(){
	var image=document.getElementById("demo");
	image.style.position="absolute";

	if(imagename == 4){
		imagename = 1;
	}	
	alert(left);
	left += 1;
	
	image.src = imagename + '.jpg';
	imagename = imagename + 1;
	image.style.left = left;
	//image.style.left=(left+1)+'px';
	//var l=document.getElementById("demo").style.left += 1;
	
}
	
</script>

</head>

<body onKeyDown='key();'>

<img src = "1.jpg" id="demo" top = 10 left = 10>


</body>
</html>

4.11. 6 7

4.11.1.

  • => . .
  • APM => 고. 기. APM_SETUP htdocs index.html 기.

4.11.2.


  • prime 기.
    // 
    public class MyTest {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		///prime  1과    . 
    		int count = 0;
    		boolean flag = false;
    		
    		for(int i = 2; i< 1000; i++){
    			
    			flag = true;
    			for(int j = 2; j<i; j++){
    				if( (i % j) == 0) flag = false;
    			}
    			
    			if(flag == true){
    				System.out.println(i + "is prime Number!");
    				count++;
    			}
    			
    		}
    		System.out.println("Count : " + count);
    		
    	}
    
    }
    

4.11.3.


5. 6 13

5.1.

5.2.

  • ? HTML -> .
  • DIV 고 x,y .


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:47
Processing time 0.0801 sec