Created
March 26, 2018 08:39
-
-
Save jwon0615/7370b1c4de75a40b633b00d2ea911031 to your computer and use it in GitHub Desktop.
1_codeup_연습문제_동적할당
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() { | |
int i,n; | |
scanf("%d",&n); | |
//int *p = (int *)malloc(sizeof(int)); | |
int *p = (int *)malloc(sizeof(int)*n); | |
for (i=0; i<n; i++) scanf("%d",p+i); | |
for (i=(n-1); i>=0; i--) printf("%d ",*(p+i)); | |
free(p); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(){ | |
int n; | |
scanf("%d", &n); | |
int *p = (int*)malloc(sizeof(int)*n); | |
//int *p = (int*)malloc(sizeof(int)); | |
for (int i = 0; i < n; i++) | |
scanf("%d", p + i); | |
for (int i = 0; i < n; i++){ | |
printf("%d: ", i+1); | |
for (int j = 0; j < n; j++){ | |
if (i == j) continue; | |
else if (*(p + i) > *(p + j)) printf("> "); | |
else if (*(p + i) < *(p + j)) printf("< "); | |
else printf("= "); | |
} | |
printf("\n"); | |
} | |
free(p); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <malloc.h> | |
int main() | |
{ | |
int a,b; | |
//char *str=(char*)malloc(sizeof(int)); | |
char *str=(char*)malloc(sizeof(int)*100); | |
scanf("%s",str); | |
scanf("%d %d",&a,&b); | |
for(int i=a-1;i<b;i++) | |
printf("%c",*(str+i)); | |
free(str); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment