This commit is contained in:
ada-dmitry
2023-04-02 21:25:54 +03:00
parent 41df1f120a
commit fec3e50d45
6 changed files with 2 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
#include "st_func.h"
#define N 5
int main(int argc, char *argv[]){
struct st1 q[N];
st_rand(q,N);
st_print(q,N);
return 0;
}
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
struct st1{
int i;
char s[128];
};
void st_rand(struct st1 temp[], int n);
void st_print(struct st1 temp[], int n);
+24
View File
@@ -0,0 +1,24 @@
#include<stdio.h>
#include<stdlib.h>
#include "st_func.h"
void st_rand(struct st1 temp[], int n){
int k;
int j;
srand(time(NULL));
for(k=0; k<n; k++){
(temp+k)->i = rand()%100;
for(j=0;j<127;j++){
(temp+k)->s[j]=((char)(65+rand()%25));
}
(temp+k)->s[127]='\0';
}
}
void st_print(struct st1 temp[], int n){
int k;
for(k=0;k<n;k++){
printf("%d->[%2d][%s]\n", k, temp[k].i, (temp+k)->s);
}
}
+8
View File
@@ -0,0 +1,8 @@
struct st1{
int i;
char s[128];
};
void st_rand(struct st1 temp[], int n);
void st_print(struct st1 temp[], int n);