mirror of
https://github.com/ada-dmitry/prog.l_ada.git
synced 2026-09-24 01:00:15 +00:00
meow2
This commit is contained in:
+11
-10
@@ -2,19 +2,16 @@
|
|||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
#include<time.h>
|
#include<time.h>
|
||||||
#include<error.h>
|
#include<error.h>
|
||||||
|
|
||||||
#define N 5
|
#define N 5
|
||||||
|
|
||||||
struct st1{
|
struct st1{
|
||||||
int i;
|
int i;
|
||||||
char s[128];
|
char s[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
void st_rand(struct st1 temp[], int n){
|
void st_rand(struct st1 temp[], int n){
|
||||||
int k;
|
int k;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
srand(time(NULL));
|
|
||||||
for(k=0; k<n; k++){
|
for(k=0; k<n; k++){
|
||||||
(temp+k)->i = rand()%100;
|
(temp+k)->i = rand()%100;
|
||||||
for(j=0;j<127;j++){
|
for(j=0;j<127;j++){
|
||||||
@@ -23,7 +20,6 @@ void st_rand(struct st1 temp[], int n){
|
|||||||
(temp+k)->s[127]='\0';
|
(temp+k)->s[127]='\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void swap(struct st1 temp[], int c, int d, int n){
|
/*void swap(struct st1 temp[], int c, int d, int n){
|
||||||
Дописать функцию!
|
Дописать функцию!
|
||||||
}
|
}
|
||||||
@@ -34,12 +30,17 @@ void st_print(struct st1 temp[], int n){
|
|||||||
printf("%d->[%2d][%s]\n", k, temp[k].i, (temp+k)->s);
|
printf("%d->[%2d][%s]\n", k, temp[k].i, (temp+k)->s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
struct st1 q[N];
|
struct st1 *pq=NULL;
|
||||||
|
srand(time(NULL));
|
||||||
st_rand(q,N);
|
|
||||||
st_print(q,N);
|
|
||||||
|
|
||||||
|
if((pq=malloc(N*sizeof(struct st1))) == NULL){
|
||||||
|
printf("malloc: NULL\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
st_rand(pq,N);
|
||||||
|
st_print(pq,N);
|
||||||
|
free(pq);
|
||||||
|
pq = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user