빨리 집 내려가서 강아지도 보고 싶고 블로그나 영어공부하면서 좀 쉬고 싶은데,,, 스케줄이 있어서
그럼 시작해볼까요?
1.Define structure (book) with following members: title and pages. Declare book type of variable, initialize the members to any values, and print it.
______________________________________________________________________4 points.
2. Declare float type of array (x) with size 5 and float type of pointer (p). Make the pointer point to array (p=x). Declare function as follows: void func (float *p). Pass your pointer to function (func(p)). Your function should store any five number on array through the pointer p and print these numbers.
______________________________________________________________________6 point.
3. Declare function as follows: void func (char *p[3], int n). Declare char pointer array(char *p[3]) and store your name on it. Pass the pointer to function (func( p, n)). Your function should print nth name.
______________________________________________________________________8 points.
4. Declare function as follows: void func1 ( char *p). Declare char pointer and store any string. Pass the pointer to function (func1 (p)). Your function should count number the of all letters (a to z) and print the result.
_____________________________________________________________________12 points.
TOTAL: 30 points
1.Define structure (class) with following members: title and number of students. Declare class type of variable, initialize the members to any values, and print it.
______________________________________________________________________4 points.
2. Declare float type of array (x) with size 5 and float type of pointer (p). Make the pointer point to array (p=x). Declare function as follows: void func (float *p). Pass your pointer to function (func(p)). Your function should store any five number on array through the pointer p and print these numbers.
______________________________________________________________________6 point.
3. Declare function as follows: void func (char *p[3], int n). Declare char pointer array(char *p[3]) and store your name on it. Pass the pointer to function (func( p, n)). Your function should print the nth letter in each name.
______________________________________________________________________8 points.
4. Declare function as follows: void func1 ( int a[10]). Declare int type of array with the size 10 and store 10 numbers on it. The numbers should be between 1-10. Pass the array to function (func1 (p)). Your function should count the number the of all numbers (1 to 10) and print the result.
_____________________________________________________________________12 points.
TOTAL: 30 points
이렇게가 기말고사였거든요? 근데 분반이 2개라서 시험지도 두 개였기 때문에, 두 개 다 올려드렸습니다.
제 답이기 때문에, 불편한 부분이 있을 수도 있는데,, 맞긴 맞아용
#1. 기말 답
#include<stdio.h>
#include<string.h>
struct book{
char title[1][20];
int pages;
};
int main()
{
int i, j, k;
struct book b;
for(int i=0; i<1; i++){
gets(b.title[i]); //first
}
scanf("%d", &b.pages);//second
for(i=0; i<1; i++){
for(j=0;j<20;j++){
printf("%c", b.title[i][j]);
if(b.title[i][j]=='\0')
break;
}
}
printf(" %d", b.pages);
}
#2. 기말 답
#include<stdio.h>
void func(float *p){
float x[5]={2.5, 3.5, 4.5, 5.5, 6.5};
for(p=x; p<x+5; p++)
printf("%f\n", *p);
}
int main(){
float *p;
float x[5];
p=x;
func(p);
}
#3. 기말 답
#include<stdio.h>
void func(char *p[3], int n){
char c[3];
for(int i=0; i<3; i++){
for(int j=0; *(p[i]+j)!='\0';j++){
c[n-1]=*(p[i]+n-1);
}
printf("%c", c[n-1]);
}
}
int main(){
char *p[3]={"choi", "jin", "hyouk"};
int n;
printf("ENTER THE NUMBER(1/2/3)");
scanf("%d", &n);
func(p, n);
}
#4. 기말 답
#include<stdio.h>
void c_l(char *p){
int i, j;
int count=0;
char k;
for(k=97; k<123; k++){
for(i=0; *(p+i)!='\0'; i++){
if(*(p+i)==k)
count++;
}
printf("%c의 개수는 %d\n", k, count);
count=0;
}
}
int main(){
char *p={"choijinhyouk"};
c_l(p);
}
이상 기말이었습니다~~~~ 이제 남은 부분은 기말 이후 부분과 제가 c로 이벤트처리하는 부분을 좋아했어서 여러 게임을 만들었는데, 그것을 설명해드릴 예정입니다. 이는 이제 python, java부분이 끝나면 하지 않을까...? 싶네요 java 이벤트를 쓰고 나서부턴 C언어는 손도 안 댔다는...
여러분 그러면 C프로그래밍 응용으로 돌아올게요
'C' 카테고리의 다른 글
(C언어) 기말고사 전 과제들 - (3) (0) | 2022.12.18 |
---|---|
(C언어) 기말고사 전 과제들 - (2) (1) | 2022.12.18 |
(C언어) 기말고사 전 과제들 - (1) (1) | 2022.12.17 |
(C언어) 기말고사 전 과제들 (1) | 2022.12.17 |
(C언어) 모의중간고사, 중간고사 (1) | 2022.12.17 |