본문 바로가기

ETC Programmings

(80)
홀수, 짝수 검사하는 프로그램 #include #include void inputNumber(int times, int* array){ int i = 0; while(i
거꾸로 해도 같은지 검사하는 프로그램(C# 버젼) using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication2 { class Test { private String str; public Test(String str) { this.str = str; } public Test() { } public void setStr(String str) { this.str = str; } public void setStr() { Console.WriteLine("검사할 문자열을 입력해줘요"); this.str = Console.ReadLine(); } public void run() { if (str == null) setStr(); Console.Write..
거꾸로 해도 같은지 검사하는 프로그램 #include #include #include int getLength(char *str){ int count = 0; for(;;){ if (*str == '\0') break; else { count++; str++; } } return count; } int compareStr(char *str1, char *str2){ int i; int isSame = 0; for(i = 0 ; i < getLength(str1) ; i++){ //printf("%c 와%c 의비교", str1[i], str2[i]); if (str1[i] == str2[i]) isSame = 1; else isSame = 0; } return isSame; } int compareReverse(char *str){ int i..
첫 Windows Application 첫 윈도우 응용 프로그램 -_-;; 이라고 하기에는 너무 부끄러운 수준이지만.. -ㅅ-;; C#으로 하는 윈도우 프로그래밍이라고 해서 크게 다를건 없었다. 확실히 이전에 비주얼 베이직으로 했던 윈도우 프로그래밍하고 비슷하다는 느낌을 받았다 문법적으로만 다를 뿐이지 GUI 프로그래밍을 한다는것 자체는 크게 다를바가 없었다. 대략 이러한 환경에서 코딩을 하게 된다. 마우스로 툭툭거리는 부분이 아직은 많지만, 하드코딩을 하는것도 중요하다고 생각하는 바이다.. -_-;; (언제 그럴날이 올지는 모르겠지만;;) 처음으로 만든 C# 프로그래밍 예제이다.. 기대 한것처럼 저런 입력 폼들은 서로 유기적으로 메세지를 교환한다. label 이라는 클래스와 TextBox 라는 클래스 그리고 Button이라는 클래스들로 이루..
atoi 함수를 이용해서 문자열의 숫자들의 합을 구하기 #include #include int checkNum(char *str); int getSize(char *str); int numCharToInt(char *str); int checkNum(char *str){ int sum = 0; int i; // 합을반영할숫자, 인덱스옮겨갈변수 char letter; for(i = 0 ; i '/' && str[i] < ':'){ letter = str[i]; sum += letter - '0'; } } return sum; } int getSize(char *str){ int size = 0; int i; for(i = 0;;i++){ if(str[..
문자열 버블정렬~ #include #include #include #define SIZE 1024 void bubbleSort(char *str); void swap(char *base, char *target); int getSize(char *str); void bubbleSort(char *str){ int i, j; for(i = 0 ; i < getSize(str) ; i++) { for (j = 0 ; j < getSize(str) ; j++) { if (str[i] < str[j]) swap(&str[i],&str[j]); } } } int getSize(char *str){ int size = 0; int i; for(i = 0;;i++){ if(str[i] == '\0') break; else size++..
단어의 갯수 골라내기 확장팩 #include #include #include #define SIZE 1024 int word_cnt(); int word_cnt(char *string){ int count = 0; int nonAlphaContinued = 0; while(*string != '\0'){ // 문장이끝날대 while (isspace(*string)) // 포인터가가르키는인덱스가공백인경우 string++; //다음인덱스로포인터를변경 if(*string != '\0'){ count++; while (!isspace(*string) && *string != '\0') { // 빈칸이아니고, 문장이끝이나지도않을때 if (isalpha(*string)) {// 알파벳인경우 string++; } else if(isalpha(*..
단어의 갯수를 세는 소스 #include #include #include #define SIZE 1024 int word_cnt(); int word_cnt(char *string){ int count = 0; while(*string != '\0'){ // 문장이 끝날대 while (isspace(*string)) // 포인터가 가르키는 인덱스가 공백인 경우 string++; //다음 인덱스로 포인터를 변경 if(*string != '\0'){ count++; while (!isspace(*string) && *string != '\0') string++; } } return count; } int main(){ char string[SIZE]; printf("입력하신 단어의 수를 세는 프로그램이다?"); gets(string..