/*
사칙연산 계산기
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d+%d=%d\n",a,b,a+b);
printf("%d-%d=%d\n",a,b,a-b);
printf("%d*%d=%d\n",a,b,a*b);
printf("%d/%d=%d\n",a,b,a/b);
return 0;
}
+ - * / %
비교연산자
> < >= <= == !=
1. 비교연산의 결과는 1또는 0으로만 나온다!!
printf("%d",a+b); // -6 7 100 108 ....여러 숫자가 나올 수 있음
printf("%d",a>b); // true 1 , false 0 둘 중 하나로 나온다.
2. <= >= != 항상 =을 오른쪽에 !!!!!
a<=b (o)
a=<b (x)
3. == vs =
a=10; (대입) a에 10을 대입해.명령!!!무조건!!!!내말들어!!!!
a==10 (비교) a와 10이 같니?? (물어보는거야~~) 대답을해줘~~
*/
/*
두 정수 입력받아 비교하기1
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a>b);
return 0;
}
*/
/*
두 정수 입력받아 비교하기2
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a==b);
return 0;
}
*/
/*
두 정수 입력받아 비교하기<=오른쪽이 더 크거나 같다
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a<=b);
return 0;
}
두 정수 입력받아 비교하기
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a!=b);
return 0;
}
논리연산자
논리값(1또는0)으로만 연산
not and or
1. not 아니다
!1 0
!0 1
0이아닌 모든수 true
0 false
!999 0
2. and 그리고 &&
printf("%d",a&&b);
a b a&&b
0 0 0
0 1 0
1 0 0
1 1 1
int a=10,b=5;
printf("%d", a<10 && b==5); // 0
3. or 또는 ||
printf("%d",a||b);
a b a||b
0 0 0
0 1 1
1 0 1
1 1 1
*/
/*
참 거짓 바꾸기
#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
printf("%d",!a);
return 0;
}
*/
/*
둘 다 참일 경우만 참 출력하기
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a&&b);
return 0;
}
*/
/*
하나라도 참이면 참 출력하기
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a||b);
return 0;
}
*/
/*
둘 다 거짓일 경우만 참 출력하기
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",!(a||b));
return 0;
}
삼항연산자
!a 단항연산자
a+b a<b 다항연산자 (2항연산자)
( 조건식 ) ? ( 조건식이참일때 ) : ( 조건식이거짓일때 )
printf("%d", 123>456 ? 10 : 100 );
-> 가장 큰 수, 또는 가장 작은수
a, b 둘 중 큰 수
printf("%d",a>b?a:b);
if(a>b)
{
printf("%d",a);
}
else
{
printf("%d",b);
}
a, b 둘 중 작은 수
printf("%d",a<b?a:b);
a, b, c세 수 중에 가장 작은 수
a<b<c (x)
a<b && b<c (o)
(a, b 둘 중 작은 수 )와 c 중 작은 수 -> 셋 중 가장 작은 수
*/
/*
두 정수 입력받아 큰 수 출력하기
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d",a>b?a:b);
return 0;
}
*/
/*
정수 3개 입력받아 가장 작은 수 출력하기
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("%d",(a<b?a:b)<c?(a<b?a:b):c);
return 0;
}
조건문
1. if-else 90%
2. switch-case 10%
#include <stdio.h>
int main()
{
int a;
scanf("%d",&a);
if(a>=100)
{
printf("hello");
}
else if(a>=50)
//else if(50<=a<100) (x)
{
printf("hi");
}
else if()
{
}
else
{
if()
{
printf("more!!");
}
else
{
}
}
return 0;
}
*/
/*
10보다 작은 수 (else 버전)
#include<stdio.h>
int main() {
int a;
scanf("%d",&a);
if(a<10)
{
printf("small");
}
else
{
printf("big");
}
return 0;
}
*/
/*
두 수의 대소 비교
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a>b)
{
printf(">");
}
else if(a<b)
{
printf("<");
}
else if(a==b)
{
printf("=");
}
return 0;
}
40을 7로 나누었을때, 나누어떨어지면 = 나머지가 0이면?
*/
/*
7의 배수
#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
if(a%7==0)
{
printf("multiple");
}
else
{
printf("not multiple");
}
return 0;
}



