Skip to content

Commit 2a03352

Browse files
committed
modified: ../c/resistor/src/main.c
renamed: ../c/r/CMakeLists.txt -> ../cmake/r/CMakeLists.txt renamed: ../c/r/main.c -> ../cmake/r/main.c renamed: ../c/r/resistor/CMakeLists.txt -> ../cmake/r/resistor/CMakeLists.txt renamed: ../c/r/resistor/build.sh -> ../cmake/r/resistor/build.sh renamed: ../c/r/resistor/resistorcal.c -> ../cmake/r/resistor/resistorcal.c renamed: ../c/r/resistor/resistorcal.h -> ../cmake/r/resistor/resistorcal.h new file: ../cmake/r1/CMakeLists.txt new file: ../cmake/r1/main.c new file: ../cmake/r1/resistor/CMakeLists.txt new file: ../cmake/r1/resistor/build.sh new file: ../cmake/r1/resistor/resistorcal.c new file: ../cmake/r1/resistor/resistorcal.h
1 parent f3ad579 commit 2a03352

File tree

13 files changed

+50
-0
lines changed

13 files changed

+50
-0
lines changed

c/resistor/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ int main(){
2222
case '1' : printf("R=%lf\n",resistorcal(r1,r2,choice));break;
2323
case '2' : printf("R2=%lf\n",resistorcal(r1,r2,choice));break;
2424
}
25+
return 0;
2526
}

c/r/main.c renamed to cmake/r/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ int main(){
2222
case '1' : printf("R=%lf\n",resistorcal(r1,r2,choice));break;
2323
case '2' : printf("R2=%lf\n",resistorcal(r1,r2,choice));break;
2424
}
25+
return 0;
2526
}

cmake/r1/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CMAKE_MINIMUM_REQUIRED(VERSION 2.9)
2+
PROJECT(RESISTOR)
3+
ADD_SUBDIRECTORY(resistor)
4+
AUX_SOURCE_DIRECTORY(. DIR_SRC)
5+
ADD_EXECUTABLE(bin ${DIR_SRC})
6+
TARGET_LINK_LIBRARIES(bin RESISTOR)

cmake/r1/main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <stdio.h>
2+
#include "resistor/resistorcal.h"
3+
int main(){
4+
printf("Welcome to Mayuri's Resistor Calculator(Only for separate routes and 2 resistor in it)\n");
5+
printf("Make your choice\n> 1.Your have the two resistors of separate routes\n> 2. Your have one of the resistors in the separate routes and the total resistor\nAny other choice is to exit\n");
6+
char choice;
7+
scanf("%c",&choice);
8+
switch (choice){
9+
case '1' : printf("Please input your args as [R1 R2]:\n");break;
10+
case '2' : printf("Please input your args as [R1 R]:\n");break;
11+
default : printf("exiting\n");return 0;break;
12+
}
13+
double r1 = -1 ,r2 = -1;
14+
scanf("%lf %lf",&r1,&r2);
15+
while ((r1<0)||(r2<0)) {
16+
printf("args don't meet the requirement(R>0)\n");
17+
printf("please input them again:\n");
18+
scanf("%lf %lf",&r1,&r2);
19+
20+
}
21+
switch (choice){
22+
case '1' : printf("R=%lf\n",resistorcal(r1,r2,choice));break;
23+
case '2' : printf("R2=%lf\n",resistorcal(r1,r2,choice));break;
24+
}
25+
return 0;
26+
}

cmake/r1/resistor/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AUX_SOURCE_DIRECTORY(. DIR_LIB_SRCS)
2+
ADD_LIBRARY(RESISTOR ${DIR_LIB_SRCS})

0 commit comments

Comments
 (0)