feat: update structure

This commit is contained in:
2024-01-22 14:27:40 +08:00
parent 7836c9185c
commit 3544a28a2e
559 changed files with 120846 additions and 4102 deletions

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# Check if we have enough arguments
# Delete temporary files
# Compile the reference program
# Generate reference output files
# Now mark submissions
#
# Note: See Lab02Qn.pdf for format of output file. Marks will be deducted for missing elements.
#
# Iterate over every submission directory
# Compile C code
# Print compile error message to output file
# Generate output from C code using *.in files in ref
# Compare with reference output files and award 1 mark if they are identical
# print score for student
# print total files marked.

View File

@@ -0,0 +1,5 @@
1
3
5
3
4

View File

@@ -0,0 +1,7 @@
382
44
112
95
hello
world
12

View File

@@ -0,0 +1,4 @@
3.4
5.4
1
2.3

View File

@@ -0,0 +1,42 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "utils.h"
#define MAX_STR_LEN 128
void strip(char *str) {
while(*str) {
if(*str == '\n')
*str = '\0';
str++;
}
}
int main() {
char str[MAX_STR_LEN];
int nums[128];
int count=0;
int res = 0;
while(!feof(stdin)) {
char *res = fgets(str, MAX_STR_LEN, stdin);
if(res){
strip(str);
int val = atoi(str);
if(val){
nums[count++] = val;
}
else
printf("%s is not a non-zero integer.\n", str);
}
}
res = sum(nums, count);
printf("Item count is %d\n", count);
printf("The sum is %d\n", res);
exit(res);
}

View File

@@ -0,0 +1,10 @@
#include "utils.h"
int sum(int sum_array[], int n) {
int i, res = 0;
for(i=0; i<n; i++)
res += sum_array[i];
return res;
}

View File

@@ -0,0 +1,2 @@
int sum(int [], int);

View File

@@ -0,0 +1,42 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "utils.h"
#define MAX_STR_LEN 128
void strip(char *str) {
while(*str) {
if(*str == '\n')
*str = '\0';
str++;
}
}
int main() {
char str[MAX_STR_LEN];
int nums[128];
int count=0;
int res = 0;
while(!feof(stdin)) {
char *res = fgets(str, MAX_STR_LEN, stdin);
if(res){
strip(str);
int val = atoi(str);
if(val){
nums[count++] = val;
}
else
printf("%s is not a non-zero integer.\n", str);
}
}
res = sum(nums, count);
printf("Item count is %d\n", count);
printf("The sum is %d\n", res);
exit(res);
}

View File

@@ -0,0 +1,10 @@
#include "utils.h"
int sum(int sum_array[], int n) {
int i, res = 0;
for(i=0; i<n; i++)
res += sum_array[i];
return res;
}

View File

@@ -0,0 +1,2 @@
int sum(int [], int);

View File

@@ -0,0 +1,40 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "utils.h"
#define MAX_STR_LEN 128
void strip(char *str) {
while(*str) {
if(*str == '\n')
*str = '\0';
str++;
}
}
int main() {
char str[MAX_STR_LEN];
int nums[128];
int count=0;
int res = 0;
while(!feof(stdin)) {
char *res = fgets(str, MAX_STR_LEN, stdin);
if(res){
strip(str);
int val = atoi(str);
if(val){
nums[count++] = val;
}
}
}
res = sum(nums, count);
printf("Item count is %d\n", count);
printf("The sum is %d\n", res);
exit(res);
}

View File

@@ -0,0 +1,10 @@
#include "utils.h"
int sum(int sum_array[], int n) {
int i, res = 0;
for(i=0; i<n; i++)
res += sum_array[i];
return res;
}

View File

@@ -0,0 +1,2 @@
int sum(int [], int);

View File

@@ -0,0 +1,42 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "utils.h"
#define MAX_STR_LEN 128
void strip(char *str) {
while(*str) {
if(*str == '\n')
*str = '\0';
str++;
}
}
int main() {
char str[MAX_STR_LEN];
int nums[128];
int count=0;
int res = 0;
while(!feof(stdin)) {
char *res = fgets(str, MAX_STR_LEN, stdin);
if(res){
strip(str);
int val = atoi(str);
if(val){
nums[count++] = val;
}
else
printf("%s is not a non-zero integer.\n", str);
}
}
res = sum(nums, count);
printf("Item count is %d\n", count);
printf("The sum is %d\n", res);
exit(res);
}

View File

@@ -0,0 +1,10 @@
#include "utils.h"
int sum(int sum_array[], int n) {
int i, res = 0;
for(i=0; i<n; i++)
res += sum_array[i];
return res;
}

View File

@@ -0,0 +1,2 @@
double sum(int [], int);

5
cs2106/labs/lab2/part1/diff.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
x=15
y=20
z=$(($x-$y))
echo "$x - $y = $z"

View File

@@ -0,0 +1,2 @@
This is a text file.
CS2106 Introduction to Operating Systems is a cool module!

View File

@@ -0,0 +1,3 @@
#!/bin/bash
echo "Hello $(whoami), today is $(date)"

View File

@@ -0,0 +1,2 @@
#!/bin/bash
echo "Hello World"

View File

@@ -0,0 +1,29 @@
#include <stdio.h>
// For the sleep functiopn
#include <unistd.h>
// For the atoi function that converts
// strings to integers
#include <stdlib.h>
int main(int ac, char **av) {
if(ac != 2) {
printf("\nCounts from specified integer n to n + 5\n");
printf("Usage: %s <integer>\n\n", av[0]);
exit(-1);
}
int n = atoi(av[1]);
int i;
for(i=n; i<=n+5; i++) {
printf("%d\n", i);
sleep(1);
}
printf("\nFinal value of i is %d\n\n", i);
exit(i);
}

View File

@@ -0,0 +1,13 @@
#include <stdio.h>
#define BUF_SIZE 128
int main() {
char input[128];
char *ret;
while(!feof(stdin)) {
ret = fgets(input, BUF_SIZE - 1, stdin);
if(ret != NULL)
printf("This is what I read: %s\n", input);
}
}