Skip to content

Instantly share code, notes, and snippets.

@jwon0615
Created March 26, 2018 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwon0615/7370b1c4de75a40b633b00d2ea911031 to your computer and use it in GitHub Desktop.
Save jwon0615/7370b1c4de75a40b633b00d2ea911031 to your computer and use it in GitHub Desktop.
1_codeup_연습문제_동적할당
#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;
}
#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);
}
#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