OIT Archive
C演習I 10
最終更新:
oit-archive
-
view
worka1.c
- #include <stdio.h>
- #include <math.h>
-
- int main(void){
- double a, b, c;
- double x, y, z;
- double rad, pai = 3.14;
-
- rad = a / 180 * pai;
-
-
-
- return 0;
- }
-
worka2.c
- #include <stdio.h>
-
- int add(int c, int d){
- int e;
- e = c + d;
-
- return e;
- }
-
- int subtract(int c, int d){
- int e;
- e = c - d;
-
- return e;
- }
-
- int multiple(int c, int d){
- int e;
- e = c * d;
-
- return e;
- }
-
- double divide(int c, int d){
- double e;
- e = (double)c / d;
-
- return e;
- }
-
- int main(void){
-
- int a, b;
- int wa, sa, seki;
- double syou;
-
-
- wa = add(a, b);
- sa = subtract(a, b);
- seki = multiple(a, b);
- syou = divide(a, b);
-
- return 0;
- }
-
worka3.c
- #include <stdio.h>
-
- int fact(int a){
- int i;
- int fra = 1;
-
- for(i=1; i<=a; i++){
- fra = fra * i;
- }
-
- return fra;
- }
-
- int main(void){
- int n, ans;
-
-
- ans = fact(n);
-
- return 0;
- }
-
worka4.c
- #include <stdio.h>
-
- void printStars(int a){
- int i;
-
- for(i=1; i<=a/10; i++){
- }
- for(i=1; i<=a%10; i++){
- }
-
- return;
- }
-
- int main(void){
- int i;
- int data[10] = {69, 63, 90, 58, 8, 22, 19, 20, 13, 74};
-
- for(i=0; i<10; i++){
- printStars(data[i]);
- }
-
- return 0;
- }
-
worka5.c
- #include <stdio.h>
-
- int sumAtoB(int a, int b){
- int i;
- int sum = 0;
-
- for(i = a; i <= b; i++){
- sum = sum + i;
- }
-
- return sum;
- }
-
- int main(void){
- int start, end;
- int total;
-
-
- total = sumAtoB(start, end);
-
- return 0;
- }
-
worka6.c
- #include <stdio.h>
-
- double squareRoot(double a){
- double root = 0.0;
-
- while(root * root < a){
- root = root + 0.0001;
- }
-
- if(root * root > a + 0.0001){
- root = root - 0.0001;
- }
-
- return root;
- }
-
- int main(void){
- double inp, kon;
-
-
- kon = squareRoot(inp);
-
- return 0;
- }
-
worka7.c
- #include <stdio.h>
-
- void BMIndex(int a, int b){
- double bmi;
-
- bmi = (double) b * 10000 / (a * a);
-
- if(bmi < 18.5){
- }else if(bmi < 25.0){
- }else if(bmi < 30.0){
- }else{
- }
-
- return;
- }
-
- int main(void){
- int height, weight;
-
-
- BMIndex(height, weight);
-
- return 0;
- }
-
worka8.c
- #include <stdio.h>
-
- int checkYear(int a){
-
- int flag = 0;
-
- if(a % 4 == 0 && a % 100 != 0 || a % 400 == 0)
- flag = 1;
-
- return flag;
- }
-
- int main(void){
-
- int i, year1, year2;
- int flag = 0, cnt = 0;
-
-
- for(i = year1; i < year2; i++){
- flag = checkYear(i);
- if(flag == 1){
- cnt++;
- }
- }
-
-
- return 0;
- }
-