반응형
#include<stdio.h>
int main()
{
	int qty, cost, result;
	
	printf("판매수량? ");
	scanf("%d", &qty);
	
	printf("단가? ");
	scanf("%d", &cost);
	
	if(qty*cost > 1000000)
		result = (qty*cost)-(qty*cost*5e-2);
	else 
		result = qty*cost;
		
	printf("판매금액 : %d \n", result);
	
	return 0;
}
/*
판매수량? 50
단가? 15000
판매금액 : 750000

--------------------------------
Process exited after 4.065 seconds with return value 0
계속하려면 아무 키나 누르십시오 . . .

판매수량? 100
단가? 15000
판매금액 : 1425000

--------------------------------
Process exited after 6.397 seconds with return value 0
계속하려면 아무 키나 누르십시오 . . .
*/
반응형

'C, C++ > 든든한 c programming 단계별 workbook' 카테고리의 다른 글

Chapter 2 중급 3  (2) 2019.08.26
Chapter2 중급 1  (0) 2019.08.26
Chapter 3 초급 2  (0) 2019.08.24
Chapter3 초급 1  (0) 2019.08.24
Chapter 2 고급2  (0) 2019.08.24
반응형
<html>
<head>
<title> SQL 테스트(php.2) </title>
</head>
<body>

<?php
include ("1.php");
$sql="select * from member";
$result = mysql_query($sql,$connect);

while ($row = mysql_fetch_row($result))
{
 echo 'ID:  '.$row[0].'  ';
 echo 'PW:  '.$row[1].'  ';
 echo 'NAME:  '.$row[2].'  ';
 echo 'E-mail:  '.$row[3].'  ';
 echo '<br>';
}
?> 

</body>
</html> ​
//php.1
<?

$DbMachine ="localhost";
$DbUser ="kjuju02";
$DbPasswd = "k5276283^";

$connect =mysql_connect ($DbMAchine,$DbUser,$DbPasswd);

mysql_select_db("kjuju02",$connect) or die ("데이터 베이스를 잘못 선택했습니다.");
mysql_set_charset ("utf-8");

?>
//insert
<?
  $id=$_POST['id'];
  $pw=$_POST['pw'];
  $name=$_POST['name'];
  $E_mail=$_POST['E_mail'];
  echo $id;
  echo "<br>";
  echo $pw;
  echo "<br>";
  echo $name;
  echo "<br>";
  echo $E_mail;
  echo "<br>";

  include("1.php");
  $sql="INSERT INTO member(id, pw, name, E_mail) VALUES('$id', '$pw;', '$name;','E_mail;')";
  $result=mysql_query($sql, $connect);

  $sql="SELECT * FROM member";
  $result=mysql_query($sql, $connect);
  while($row=mysql_fetch_row($result))
  {
	echo 'ID: '.$row[0].'  ';
	echo 'PW: '.$row[1].'  ';
    echo 'NAME: '.$row[2].'  ';
    echo 'E_mail: '.$row[3].'  ';
    echo '<br>';
  }
?>
	<form action="in.php" method="post" name="insert">
	I&nbsp;&nbsp;D:<input type="text" name="id" value=""><BR>
	P&nbsp;&nbsp;W:<input type="text" name="pw" value=""><BR>
	NAME:<input type="text" name="name" value=""><BR>
	E-mail:<input type="text" name="E_mail" value=""><BR>

	<input type="submit" name="run" value="실행">
//delete
<?
  $id=$_POST['id'];
  $pw=$_POST['pw'];
  $name=$_POST['name'];
  $E_mail=$_POST['E_mail'];
  echo $id;
  echo "<br>";
  echo $pw;
  echo "<br>";
  echo $name;
  echo "<br>";
  echo $E_mail;
  echo "<br>";

  include("1.php");
  $sql="DELETE FROM member WHERE id='$id'";
  $result=mysql_query($sql, $connect);
  $sql="SELECT * FROM member";
  $result=mysql_query($sql, $connect);
  echo "<table border=1>";
  while($row=mysql_fetch_row($result))
  {
  	echo "<tr>";
	echo "<td>";echo 'ID: '; echo "</td>";
	echo "<td>";echo $row[0]; echo "</td>";
	echo "<td>";echo 'PW: '; echo "</td>";
	echo "<td>";echo $row[1]; echo "</td>";
	echo "<td>";echo 'NAME: '; echo "</td>";
	echo "<td>";echo $row[2]; echo "</td>";
	echo "<td>";echo 'mail: '; echo "</td>";
	echo "<td>";echo $row[3]; echo "</td>";
	echo "</tr>";
  }
  echo "</table>";
?>

	<form action="de.php" method="post" name="insert">
	I&nbsp;&nbsp;D:<input type="text" name="id" value=""><BR>
	P&nbsp;&nbsp;W:<input type="text" name="pw" value=""><BR>
	NAME:<input type="text" name="name" value=""><BR>
	E-mail:<input type="text" name="E_mail" value=""><BR>

	<input type="submit" name="run" value="실행">
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

Array2  (0) 2019.08.26
Array  (0) 2019.08.26
table  (0) 2019.08.26
케이스  (0) 2019.08.26
대소 비교  (0) 2019.08.26
반응형
<?php
	$town=array(
		"seoul"=>array(
			"eunpyung", "sungdong", "kangnam"
			),

		"busan"=>array(
			"haeundae", "saha", "yeongdo")
		    );
	//saha가 출력된다.
	
	print ($town["busan"][1]);
?>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

insert - delete  (0) 2019.08.26
Array  (0) 2019.08.26
table  (0) 2019.08.26
케이스  (0) 2019.08.26
대소 비교  (0) 2019.08.26
반응형
<?php
  $user["name"]="홍길동";
  $user["age"]=28;
  $user["job"]="회사원";
  //루프를 돌면서 배열의 값을 출력한다.

  foreach($user as $value)
  {
  	print $value . "<br/>";
  }

  print "<br/>";
  //루프를 돌면서 배열의 키와 값을 출력한다.

  foreach($user as $key => $value)
  {
  	print $key . " ? " . $value . "<br/>";
  }
?>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

insert - delete  (0) 2019.08.26
Array2  (0) 2019.08.26
table  (0) 2019.08.26
케이스  (0) 2019.08.26
대소 비교  (0) 2019.08.26
반응형
<?php
   print "table 출력<br/><br/>";

   print"<table border=1>";

   print "<tr>";
   print "  <td>라인 수</td>";
   print "  <td>\$i의 값</td>";
   print "</tr>";

   $i=0;
   while($i < 10)
   {
   	print "<tr>";
	print "  <td>".($i+1)."라인</td>";
	print "  <td>".$i."</td>";
	print "</tr>";
	$i++; 
  }
print "</table>";

print "<br/>10 라인이 생성되었습니다.";
?>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

Array2  (0) 2019.08.26
Array  (0) 2019.08.26
케이스  (0) 2019.08.26
대소 비교  (0) 2019.08.26
단항 연산자  (0) 2019.08.25
반응형
<?php
$i=0;
switch($i)
{
	case 0:
		print "1는 0과 같다.";
		break;
	case 1:
		print "1는 1과 같다.";
		break;
	case 2:
		print "1는 2와 같다.";
		break;

	}
?>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

Array  (0) 2019.08.26
table  (0) 2019.08.26
대소 비교  (0) 2019.08.26
단항 연산자  (0) 2019.08.25
화면에 출력하기  (0) 2019.08.25
반응형
<?php
$a=3;
$b=7;
if($a > $b)
{
	print "a는 b보다 크다";
}

elseif($a < $b)
{
	print "a는 b보다 작다";
}
else
{
	print "a와 b는 같다";
}
?>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

table  (0) 2019.08.26
케이스  (0) 2019.08.26
단항 연산자  (0) 2019.08.25
화면에 출력하기  (0) 2019.08.25
BOX  (0) 2019.08.25
반응형
#include <stdio.h>
#include <stdlib.h>
#define MAX_VERTICES 8 // 노드 최고 개수 8 
#define FALSE 0
#define TRUE 1
typedef struct node *node_point; //선언자  
typedef struct node
{
	int vertex; // 번호 
	node_point link;
};
node_point graph[MAX_VERTICES];
short int visited[MAX_VERTICES]; // 방문기록-배열  
typedef struct queue *queue_point;
typedef struct queue
{
	int vertex;
	queue_point link;
};
node_point createnode(int data);
void bfs (int vertex); // BFS함수 선언 
void addq(queue_point *, queue_point *, int);
int deleteq (queue_point *front); 
int main()
{
	graph[0] = createnode(1);
	graph[0]->link = createnode(2);
	graph[1] = createnode(0);
	graph[1]->link = createnode(3);
	graph[1]->link->link = createnode(4);
	graph[2] = createnode(0);
	graph[2]->link = createnode(5);
	graph[2]->link->link = createnode(6);
	graph[3] = createnode(1);
	graph[3]->link = createnode(7);
	graph[4] = createnode(1);
	graph[4]->link = createnode(7);
	graph[5] = createnode(2);
	graph[5]->link = createnode(7);
	graph[6] = createnode(2);
	graph[6]->link = createnode(7);
	graph[7] = createnode(3);
	graph[7]->link = createnode(4);
	graph[7]->link->link = createnode(5);
	graph[7]->link->link->link = createnode(6);
	printf(" : "); // 정점의 운행 순서
	bfs(0); // 0번 호출
	printf(" \n"); // 끝
}

/* 노드 생성을 위한 함수  */
node_point createnode(int data)
{
	node_point ptr;
	ptr = (node_point)malloc(sizeof(struct node)); //메모리 확보 
	ptr->vertex = data;
	ptr->link = NULL;
	return ptr;
}

void bfs (int v)
{
	node_point w;
	queue_point front, rear;
	front = rear = NULL;
	printf("V%d-> ", v);
	visited[v] = TRUE;
	addq (&front, &rear, v);
	while (front)
	{
		v = deleteq (&front);
		for (w=graph[v]; w;w=w->link)
		if (!visited[w->vertex])
		{
			printf ("V%d-> ", w->vertex);
			addq (&front, &rear, w->vertex);
			visited[w->vertex] = TRUE;
		}	
	}
}
void addq (queue_point *front, queue_point *rear, int data)
{
	queue_point temp;
	temp = (queue_point)malloc(sizeof(struct queue));
	temp->vertex = data;
	temp->link = NULL;
	if (*front)
	(*rear)->link = temp;
	else
	*front = temp;
	*rear = temp;	
}
int deleteq (queue_point *front)
{
	queue_point temp;
	int data;
	temp = *front;
	data = temp->vertex;
	*front = temp->link;
	free(temp);
	return data;
}
/*
 : V0-> V1-> V2-> V3-> V4-> V5-> V6-> V7->

--------------------------------
Process exited after 0.01723 seconds with return value 0
계속하려면 아무 키나 누르십시오 . . .
*/	
반응형

'2019~2020 > 자료구조' 카테고리의 다른 글

버블정렬  (0) 2019.09.11
최댓값 찾기 알고리즘  (0) 2019.09.03
행렬을 이용한 BFS (c)  (0) 2019.08.20
연결 리스트 DFS (c)  (0) 2019.08.16
그래프의 탐색  (0) 2019.08.12
반응형
<?php
$a=5;
print $a++; //5가 출력, $a를 1증가
print $a; //6 출력

$a=5;
print ++$a; //1 증가된 값이 $a에 대입 6이 출력
print $a; //6 출력

$a=5;
print $a--; //5 출력, %a 1 감소
print $a; //4출력

$a=5;
print --$a; //1 감소된 값이 $a에 대입, 4출력
print $a; //4가 출력
?>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

케이스  (0) 2019.08.26
대소 비교  (0) 2019.08.26
화면에 출력하기  (0) 2019.08.25
BOX  (0) 2019.08.25
박스 모델  (0) 2019.08.25
반응형
<!doctype html>
<html lang="en">
 <head>
    <title>화면에 출력</title>
 </head>
 <body>
 <?php
 	echo("Hello<br>");
	echo("PHP의 세계에 오신 것을 환영합니다.<br>");
	print("우리 함께 PHP로 여행을 떠나요 *^^*");
   ?>
 </body>
</html>
반응형

'2019~2020 > 웹 프로그래밍 (PHP)' 카테고리의 다른 글

대소 비교  (0) 2019.08.26
단항 연산자  (0) 2019.08.25
BOX  (0) 2019.08.25
박스 모델  (0) 2019.08.25
웹 폰트 적용하기  (0) 2019.08.25

+ Recent posts