Skip to content

Instantly share code, notes, and snippets.

@jwon0615 jwon0615/1402.cpp
Created Mar 26, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.