anonymous No title
C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int Amax(int *p,int size){
   int _max = 0;
   for(int i = 0;i < size;i++)
      if(p[i] > _max)_max = p[i];
   return _max;
}

int main(){
   int n;scanf("%d",&n);
   char paper[200000][11];for(int i = 0;i < n;i++)scanf("%s",paper[i]);
   char tmp[11];
   int count[200000] ={0};
   int pointer;
   for(int i=1;i<n;i++){
      for(int j=1;j<n;j++){
         if(strcmp(paper[j-1], paper[j])>0){
            strcpy(tmp, paper[j-1]);
            strcpy(paper[j-1], paper[j]);
            strcpy(paper[j], tmp);
         }
      }
   }
   pointer = 0;
   for(int i = 0;i < n-1;i++){
      if (!(strcmp(paper[i],paper[i+1]))){
         count[pointer]++;
      }else {
         pointer = i+1;
      }
   }
   /*for(int i = 0;i < n;i++){
      printf("%d\n",count[i]);
      printf("%s\n",paper[i]);
   }*/

   int x = Amax(count,n);
   for(int i = 0;i < n;i++){
      if(count[i] == x)printf("%s\n",paper[i]);
   }
}
anonymous No title
C
#include<stdio.h>
#include<stdlib.h>
struct SEITO{
 char ID;
 int  sj;
 int  sm;
 int  se;
};
int main()
{
struct SEITO seito;


 FILE *f ;
 float x[100], xmax ;
 int i,j,a,b,c,d;
 char ID[50];
 int sj[50];
 int sm[50];
 int se[50] ;
  
if((f= fopen("final_150217.txt","r"))== NULL)
{ printf("Can't open file: %s\n","final_150217.txt")  ;
   return 1 ;
 }else{
 	 printf("Opened file;%s\n","final_150217.txt");
  }
  
 for(i=0 ; i<10 ; i=i+1 ){ 
 if(fscanf(f,"%s %d %d %d",ID,&sj,&sm,&se)!=4)
   { 
    break;
    }
  }
 fclose(f);
  printf("a\n");
 for(i=0 ; i<9 ;i++)
 {
   x[i]=sj[i]+sm[i]+se[i];
   printf("b\n");
 }
 for(i=0 ; i<9 ; i++)
  { printf("c\n");
   for(j=1+i ;j<10 ;j++)
   {printf("d\n");
 	 if(x[i]<x[j]) 
 	 {
       xmax =x[i];
       x[i]=x[j];
       x[j]=xmax;
      }
    }
   }
 printf("点:%d\n",xmax);
 printf("一位:ID:%s\n",ID[i]) ;
 printf("二位:ID:%s\n",ID[i]) ;
 printf("三位:ID:%s\n",ID[i]) ;
return 0 ;
}
anonymous No title
C
#include<stdio.h>
#include<stdlib.h>
struct STUDENT{
    char ID;
    int score_j;
    int score_m;
    int score_e;
};
struct SUM_POINT{
    char ID;
    int sum;
};
int main(int argc, char *argv[]) {
    //初期化
    struct STUDENT student[10];
    struct SUM_POINT sum_point[10];
    FILE *studentfile;
    char str[2];
    int d_j, d_m, d_e;
    int flag = 1;
    char change_ID[2];
    int change_sum;
    
    if((studentfile=fopen("x.txt","r"))==NULL){
        printf("Can't open file: %s¥n","x.txt" );
        return 1;  
    }else{
        printf("File ; %s is opened","x.txt");
    }
    
    //ファイルから構造体へ代入
    for(int i= 0 ; i<10 ; i++){
        fscanf(studentfile,"%s %d %d %d", str, &d_j, &d_m, &d_e);
        strcpy(student[i].ID, str);
        strcpy(sum_point[i].ID, str);
        student[i].score_j = d_j;
        student[i].score_m = d_m;
        student[i].score_e = d_e;
        sum_point[i].sum = d_j + d_m + d_e;
    }
    fclose(studentfile);
    
    //ここから並べ替え(ソート)を行う
    while(flag){
        int inner_flag = 1;
        for(int i = 0; i < 9; i++){
            if(sum_point[i].sum < sum_point[i + 1].sum){
                change_sum = sum_point[i].sum;
                sum_point[i].sum = sum_point[i + 1].sum;
                sum_point[i + 1].sum = change_sum;
                strcpy(change_ID, sum_point[i].ID);
                strcpy(sum_point[i].ID, sum_point[i + 1].ID);
                strcpy(sum_point[i + 1].ID, change_ID);
                inner_flag = 0;
            }
        }
        if(inner_flag){
            flag = 0;
        }
    }
    //最後に出力を行う
    printf("一位: ID:%s",sum_point[0].ID)
    printf("二位: ID:%s",sum_point[1].ID)
    printf("三位: ID:%s",sum_point[2].ID)
    return 0 ;
}
anonymous No title
C
#include<stdio.h>
#include<stdlib.h>
struct STUDENT{
    char ID;
    int score_j;
    int score_m;
    int score_e;
};
struct SUM_POINT{
    char ID;
    int sum;
};
int main(int argc, char *argv[]) {
    //初期化
    struct STUDENT student[10];
    struct SUM_POINT sum_point[10];
    FILE *studentfile;
    char str[2];
    int d_j, d_m, d_e;
    bool flag = true;
    char change_ID[2];
    int change_sum;
    
    if((studentfile=fopen("x.txt","r"))==NULL){
        printf("Can't open file: %s¥n","x.txt" );
        return 1;  
    }else{
        printf("File ; %s is opened","x.txt");
    }
    
    //ファイルから構造体へ代入
    for(int i= 0 ; i<10 ; i++){
        fscanf(studentfile,"%s %d %d %d", str, &d_j, &d_m, &d_e);
        strcpy(student[i].ID, str);
        strcpy(sum_point[i].ID, str);
        student[i].score_j = d_j;
        student[i].score_m = d_m;
        student[i].score_e = d_e;
        sum_point[i].sum = d_j + d_m + d_e;
    }
    fclose(studentfile);
    
    //ここから並べ替え(ソート)を行う
    while(flag){
        bool inner_flag = true;
        for(int i = 0; i < 9; i++){
            if(sum_point[i].sum < sum_point[i + 1].sum){
                change_sum = sum_point[i].sum;
                sum_point[i].sum = sum_point[i + 1].sum;
                sum_point[i + 1].sum = change_sum;
                strcpy(change_ID, sum_point[i].ID);
                strcpy(sum_point[i].ID, sum_point[i + 1].ID);
                strcpy(sum_point[i + 1].ID, change_ID);
                inner_flag = false;
            }
        }
        if(inner_flag){
            flag = false;
        }
    }
    //最後に出力を行う
    printf("一位: ID:%s",sum_point[0].ID)
    printf("二位: ID:%s",sum_point[1].ID)
    printf("三位: ID:%s",sum_point[2].ID)
    return 0 ;
}
まんだげり No title
C
#include<stdio.h>
#include<math.h>

double f(double x){
    return pow(x,2)+2*x+1;//define function
}

double h(double a,double b,int i){
    return (b-a)/pow(2,i-1);//define h
}

void trapezoid(double a,double b,double r[100][100],int n){
    //fuction of calculating trapezoidal rule
    int i,j;
    double sum = 0;
    for(i=1;i<=n;i++){
        for(j=1;j<=pow(2,i-2);j++){
            sum += f(a+(2*j-1)*h(a,b,i));
        }
        r[i][0] = (r[i-1][0]+h(a,b,i-1)*sum);   
    }
}
void richardson(double r[100][100],int n){
    //function of extrapolation of richardson
    int i,j;
    for(i=1;i<=n;i++){
        for(j=1;j<pow(2,i-1);j++){
            r[i][j] = r[i][j-1]+(r[i][j-1]-r[i-1][j-1])/pow(4,j-1)-1;
        }
    }
}

int main(){
    double a = 0.0;
    double b = 10.0;
    int n = 5;
    int i,j,k;
    double r[n][n];
    r[0][0] = h(a,b,1)/2*(f(a)+f(b));
    /*printf("%f\n",a);
    k = h(a,b,1);
    printf("%f\n",k);*/
    printf("%f\n",r[0][0]);//1
    trapezoid(a,b,r,n);
    printf("%f\n",r[0][0]);//2
    richardson(r,n);
    printf("%f\n",r[0][0]);//3
    for(i=1;i<=n;i++){
        for(j=0;j<=i;j++){
            printf("%f ",r[i][j]);
        }
        printf("\n");
    }
    return 0;
}
anonymous No title
C
#include <stdio.h>
#include <stdlib.h>
#include<math.h>

static  const  int  NMAX = 128;
static  double  xtmp[NMAX][3];
static  double k[NMAX][3], k1[NMAX][3], k2[NMAX][3], k3[NMAX][3], k4[NMAX][3];
static  double l[NMAX][3], l1[NMAX][3], l2[NMAX][3], l3[NMAX][3], l4[NMAX][3];

void  gravity( double  (*x)[3],  double *m, double  (*a)[3],double *p, const int n){
	int i,j;
	for(i=0; i<n; i++){
		a[i][0]=a[i][1]=a[i][2]=p[i]=0.0;
		for(j=0;j<n;j++){
			if(i==j) continue;
			double dx = x[i][0] - x[j][0];
			double dy = x[i][1] - x[j][1];
			double dz = x[i][2] - x[j][2];
			double r2 = dx*dx + dy* +dz*dz;
			double rinv = 1.0 / sqrt(r2);
			double mjr3inv = m[j]*rinv*rinv*rinv;
			a[i][0] -= mjr3inv * dx;
			a[i][1] -= mjr3inv * dy;
			a[i][2] -= mjr3inv * dz;
			p[i]    -= m[j] * rinv;
		}
	}
}



double  energy( double  (*v)[3],  double *m, double *p, const  int n){

  double e = 0.0;
  int i;
  for(i=0;i<n;i++){
	e += p[i] + m[i]*(v[i][0]*v[i][0]+v[i][1]*v[i][1]+v[i][2]*v[i][2])/2;  
	}
	return e;
}


void  runge2( double  (*x)[3],  double  (*v)[3],  double *m, double  (*a)[3],
	double *p, const  double dt , const  int n){
	int i,h;
	gravity(x,m,a,p,n);
	for(i=0;i<n;i++){
		for(h=0;h<3;h++){
			k1[i][h] = v[i][h]*dt;
			l1[i][h] = a[i][h]*dt;
			xtmp[i][h] = x[i][h] + (k[i][h]/2);
		}
	}

	gravity(xtmp,m,a,p,n);
	for(i=0;i<n;i++){
		for(h=0;h<3;h++){
			k2[i][h] = (v[i][h] + l1[i][h]*dt);
			l2[i][h] = a[i][h] * dt;
		}
	}

	for(i=0;i<n;i++){
		for(h=0;h<3;h++){
			k[i][h] = (k1[i][h] + k2[i][h])/2;
			k[i][h] = (k1[i][h] + k2[i][h])/2;
			x[i][h] += k[i][h];
			v[i][h] += l[i][h];
			}
	}
}


int  main (){

	double x[NMAX ][3];
	double v[NMAX ][3];
	double a[NMAX ][3];
	double m[NMAX];
	double p[NMAX];
	int n,i,j;
	double dt,tend;
	double e0;
	double tnow =0.0;
	double e;
	FILE *file1;	
	FILE *file2;	
	FILE *file3;	
	FILE *file4;		
	
	file1 = fopen("rung2_1.dat", "w");
	file2 = fopen("rung2_2.dat", "w");
	file3 = fopen("rung2_3.dat", "w");
	file4 = fopen("e_rung2.dat", "w");


	printf("input n,dt,tend,m,x,v");
	scanf("%d,%lf,%lf",n,dt,tend);
	for(i=0;i<n; i++){
		scanf("%lf",m[i]);
		for(j=0; j<3; j++){
			scanf("%lf",x[i][j]);
		}
		for(j=0; j<3; j++){
			scanf("%lf",v[i][j]);
		}
	}
	gravity(x,m,a,p,n);
	e0 = energy(v,m,p,n);

	/*printf("%lf\t",tnow):
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
		printf("%lf\t",x[i][j]);
	}*/
	while(tnow < tend){

	runge2(x,v,m,a,p,dt,n);
	e = energy(v,m,p,n);
	tnow += dt;

	/*printf("%lf\t",tnow):
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
		printf("%lf",x[i][j]);
	}
	printf("%lf\t",e);
	printf("%lf\t",(e-e0)/e0);*/
	
		
	fprintf(file1, " %lf %lf\n",x[0][0],x[0][1]);
    	fprintf(file2, " %lf %lf\n",x[1][0],x[1][1]);
	fprintf(file3, " %lf %lf\n",x[2][0],x[2][1]);
	fprintf(file4, " %lf %lf\n",tnow,(e-e0)/e0);
	
	fclose(file1);
	fclose(file2);
	fclose(file3);
	fclose(file4);	

	}
	

}
anonymous No title
C
anonymous No title
C
int digitalPin0 = 3;
int digitalPin1 = 5;
int digitalPin2 = 6;
int digitalInputPin0 = 7;
int analogInputPin0 = 3;

void setup(){
  pinMode(digitalPin0, OUTPUT);
  pinMode(digitalPin1, OUTPUT); 
  pinMode(digitalPin2, OUTPUT);
  pinMode(digitalInputPin0, INPUT);

 Serial.begin(9600);
}

int b;

void loop(){
  int d = digitalRead(digitalInputPin0);
  int e = analogRead(analogInputPin0);
  digitalWrite(digitalPin0,LOW);
  digitalWrite(digitalPin1,LOW);
  digitalWrite(digitalPin2,LOW);
  b = 0;

  while(d == 0){
    b++;
    if(b == 20){
      digitalWrite(digitalPin0,HIGH);
      int e = analogRead(analogInputPin0);
      // if(e>=1)ですか?
      if(e > 1)
        // b=0はbに0を代入、b==0はbが0かどうか判定するだけでbの値は変わらない
        b == 0;
    
    }else if(b == 40){
      digitalWrite(digitalPin1,HIGH);
      int e = analogRead(analogInputPin0);
      if(e > 1)
        b == 0;
    }else if(b == 60){
      digitalWrite(digitalPin2,HIGH);
      int e = analogRead(analogInputPin0);
      if(e > 1)
        b == 0;
    }
  }
}
( ◜ᴗ¯) No title
C
#define N 3
#define EPS 1.0e-8

/* 第26行で定義している余因子を求める関数を宣言し, calc_determinant関数でこの関数を使用できるようにする */
double calc_cofactor_determinant(int n, double matrix[][n], int row, int column);

/* n*n行列の行列式を余因子から求める */
double calc_determinant(int n, double matrix[][n]) {
	int i, j;
	if (n < 3) {
		return n == 2 ? matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0] : 0;
	} else {
		double determinant = 0;
		for (i = 0; i < n; i++) {
			determinant += matrix[i][0] * calc_cofactor_determinant(n, matrix, i, 0);
		}
		return determinant;
	}
}

/* n*n行列matrixのrow, column成分の余因子を求める */
double calc_cofactor_determinant(int n, double matrix[][n], int row, int column) {
	int i, j, add_index_i = 0, add_index_j = 0;
	double cofactor[n - 1][n - 1];
	for (i = 0; i < n; i++) {
		if (i == row) { // column行の成分は無視する
			continue;
		}
		add_index_j = 0;
		for (j = 0; j < n; j++) {
			if (j == column) { // row列の成分は無視する
				continue;
			}
			cofactor[add_index_i][add_index_j] = matrix[i][j];
			add_index_j++;
		}
		add_index_i++;
	}
	return ((row + column) % 2 == 0 ? 1 : -1) * calc_determinant(n - 1, cofactor);
}

/* n*n行列matrixの逆行列inversedを求める */
int calc_inverse_matrix(double matrix[][N], double inversed[][N]) {
	int i, j;
	double determinant = calc_determinant(N, matrix); // matrixの行列式
	if (determinant == 0) { // 行列式が0であった場合はエラー処理
		printf("determinant is 0");
		return 0;
	}
	/* ji成分の余因子から逆行列のij成分を求める */
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			inversed[i][j] = calc_cofactor_determinant(N, matrix, j, i) / determinant;
		}
	}
	return 1; // 逆行列が正常に作られたことを示す
}
anonymous No title
C
#include<stdio.h>
#define num 10

void mergesort(int ary[], int left, int right){

    int i, j, k, mid;
    int temp[num];

    if(left < right){

        mid = (left + right)/2;

        mergesort(ary, left, mid);
        mergesort(ary, mid + 1, right);

        for(i = left; i <= mid; i++){
            temp[i] = ary[i];
        }

        for(j = mid + 1; j <= right; j++){
            temp[right - (j - (mid + 1))] = ary[j];
        }

        i = left, j = right;

        for(k = left; k <= right; k++){
            if(temp[i] < temp[j]){
                ary[k] = temp[i];
                i++;
            }
            else{
                ary[k] = temp[j];
                j--;
            }
        }
    }
}

void merge(int ary1[], int ary2[], int ary3[]){
    int i, j, k;
    i = j = k = 0;

    for(; k < num * 2; k++){
        if(ary1[i] < ary2[j]){
            ary3[k] = ary1[i];
            i++;
        }
        else{
            ary3[k] = ary2[j];
            j++;
        }
    }
}

int main(void){
    int ary1[num], ary2[num], ary3[num * 2];

    for(int i = 0; i < num; i++){
        scanf("%d",&ary1[i]);
    }

    for(int i = 0; i < num; i++){
        scanf("%d",&ary2[i]);
    }

    mergesort(ary1,0,num - 1);

    mergesort(ary2,0,num - 1);

    for(int i = 0; i < num; i++){
        printf("%d,", ary1[i]);
    }
    printf("\n");

    for(int i = 0; i < num; i++){
        printf("%d,", ary2[i]);
    }
    printf("\n");

    merge(ary1, ary2, ary3);

    for(int i = 0; i < num * 2; i++){
        printf("%d, ",ary3[i]);
    }

    printf("\n");
}
Don't you submit code?
Submit