실습과제 #1

개발/Algorithm 2014. 9. 19. 12:51

19.

#include<iostream> // std와 << 연산자를 위한 iostream 참조
using namespace std; //std 생략을 위한 선언

int main(void){
 int age = 20;
 char * pDept = "컴퓨터 공학과";
 cout << age <<" "<< pDept << endl;
}

 

20.

/* date : 2014-09-19       *
 * class : C++ Programming *
 * Student ID : 5112648    *
 * name : 김정빈            *
 */


#include<iostream> // std와 << 연산자를 위한 iostream 참조
using namespace std; //std 생략을 위한 선언

int main(void){
 int count = 1;                     
for( int n = 0 ; n<4; n++){      // count 변수를 선언하여 별의 개수 조절
  for(int i = 0; i<count; i++){
   cout << "*";
  }
  cout << endl;
  count++;
 }

 return 0;
}

 

12.

 

/* date : 2014-09-19       *
 * class : C++ Programming *
 * Student ID : 5112648    *
 * name : 김정빈            *
 */


#include<iostream> // std와 << 연산자를 위한 iostream 참조
using namespace std; //std 생략을 위한 선언
int sum(int a, int b);

int main(void){
 int n = 0;
 cout << "끝 수를 입력하세요 >>";
 cin >> n;
 cout << "1에서 " << n << "까지의 합은 " << sum(1 ,n) << "입니다." << endl;
 return 0;
}

int sum(int a,int b){
 int k, res=0;
 for(k = a ; k<=b; k++){
  res += k;
 }
 return res;
}

 

14.

 

/* date : 2014-09-19       *
 * class : C++ Programming *
 * Student ID : 5112648    *
 * name : 김정빈            *
 */


#include<iostream> // std와 << 연산자를 위한 iostream 참조
#include<string>
using namespace std; //std 생략을 위한 선언
#define MAX_CHAR_SIZE 10000 // 문자열 배열의 최댓값

void check_char_is_alpha(char *c);
void to_alpa_changer(char *c);

int main(void){
 char ch[MAX_CHAR_SIZE];
 char abc[27];
 cin.getline(ch,10000,';');
 change_to_alpa(ch);
 cout << ch;
 
 

 return 0;
}
void change_to_alpa(char *c){
 for( int i = 0; i<MAX_CHAR_SIZE; i++){
  c[i] = (char)tolower(c[i]);
 }
}
void check_char_is_alpha(char *c,char *eng){

 int temp;
 for(int i = 0; i<MAX_CHAR_SIZE; i++){
  if((char)isalpha(c[i])){
   temp = atoi(c) - 97;
   eng[temp]++;
  }
 }
}

 

 

'개발 > Algorithm' 카테고리의 다른 글

Selection Sort  (0) 2014.09.23
실습과제 #1 14  (0) 2014.09.19
원을 만드는 것  (0) 2014.09.12
이진 트리의 연산 // 노드,단말노드의 개수  (0) 2014.06.02
레벨 순회 프로그램  (0) 2014.06.02
블로그 이미지

잉비니

,