anonymous No title
C++
#include "stdio.h"

//階乗関数
double fact(double k) {
	double y,i;
	y = 1;
	for (i = 1; i <= k;i++) {
		y = y * i;
	}
	return(y);
}

//自然対数01
int main() {
	double s, i;
	s = 0;

	for (i = 0; i <= 20; i++) {
		s += 1 / fact(i);
	}

	printf("%lf",s);
}

//自然対数02
int main() {
	double s, p, i;
	s = 1 , p = 1;

	for (i = 1; i <= 20; i++) {
		p = p / i;
		s += p;
	}

	printf("%lf",s);
}

//組み合わせ01
int main() {
	double c, n, r, i;

	//入力
	printf("n=");
	scanf_s("%lf",&n);
	printf("r=");
	scanf_s("%lf",&r);

	c = fact(n) / (fact(r)*fact(n-r));

	printf("%lf",c);
}
りゅうちゃん@hパラメータ No title
C++
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

int main() {
	double sum, ave, max, sd, devi;
	int count;
	int rand_nums [10];

	//変数初期化
	sum = 0, ave = 0, max = 0, sd = 0, devi = 0;

	//乱数配列 --1から100の乱数--
	srand(100);
	for (count = 0; count < 10; count++) {
		rand_nums [count] = rand() % 100 +1;
	}

	//##############################################################

	//合計
	for (count = 0; count < 10; count++) {
		sum += rand_nums [count];
	}

	//平均
	ave = sum / 10;

	//最大
	max = rand_nums[0];
	for (count = 1; count < 10; count++) {
		if (max < rand_nums [count]) {
			max = rand_nums[count];
		}
	}

	//標準偏差
	for (count = 0; count < 10; count++) {
		devi += pow((rand_nums [count] - ave),2);
	}
	sd = sqrt(devi / 10);

	//##############################################################

	//表示
	printf("乱数:");
	for (count = 0; count < 10; count++) {
		printf("%d,", rand_nums [count]);
	}
	printf("\n合計:%lf\n平均:%lf\n最大:%lf\n標準偏差:%lf\n", sum, ave, max, sd);

	return 0;
}
りゅうちゃん@hパラメータ No title
C++
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int a[100], n, i,s,h,z,x;
    float j;
    srand(100);
    printf("Input n=?\n");
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        a[i]=rand()%100;
        printf("a[%d]=%d\n",i,a[i]);

    }
    s=0;
    z=0;
    x=0;
    for(i=1;i<=n;i++){
        s=s+a[i];
        if(a[i]>z){
            z=a[i];
        }else{
        }

    }
    h = s / n;
    for(i=1;i<=n;i++){
        x=x+((a[i]-h)*(a[i]-h));
    }
    j=sqrt(x/n);
    printf("sum=%d\n",s);
    printf("avarage=%d\n",h);
    printf("max=%d\n",z);
    printf("標準偏差=%f",j);
}
anonymous No title
C++
#include "stdio.h"

//階乗関数
double fact(double k) {
	double y,i;
	y = 1;
	for (i = 1; i <= k;i++) {
		y = y * i;
	}
	return(y);
}

int main() {
	double c, n, r, i;

	//入力
	printf("n=");
	scanf_s("%lf",&n);
	printf("r=");
	scanf_s("%lf",&r);

	c = fact(n) / (fact(r)*fact(n-r));

	printf("%lf",c);
}
anonymous No title
C++
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

int main() {
	double sum, ave, max, sd, devi;
	int count;
	int rand_nums [10];

	//変数初期化
	sum = 0, ave = 0, max = 0, sd = 0, devi = 0;

	//乱数配列 --1から100の乱数--
	for (count = 0; count < 10; count++) {
		rand_nums [count] = rand() % 100 +1;
	}

	//##############################################################

	//合計
	for (count = 0; count < 10; count++) {
		sum += rand_nums [count];
	}

	//平均
	ave = sum / 10;

	//最大
	max = rand_nums[0];
	for (count = 1; count < 10; count++) {
		if (max < rand_nums [count]) {
			max = rand_nums[count];
		}
	}

	//標準偏差
	for (count = 0; count < 10; count++) {
		devi += pow((rand_nums [count] - ave),2);
	}
	sd = sqrt(devi / 10);

	//##############################################################

	//表示
	printf("乱数:");
	for (count = 0; count < 10; count++) {
		printf("%d,", rand_nums [count]);
	}
	printf("\n合計:%lf\n平均:%lf\n最大:%lf\n標準偏差:%lf\n", sum, ave, max, sd);

	return 0;
}
anonymous No title
C++
#include<bits/stdc++.h>
using namespace std;
int main(){
cout<<"hello"<<endl;
}
anonymous No title
C++
#include <Arduino.h>

#if defined( ARDUINO_M5Stack_Core_ESP32 ) || defined( ARDUINO_M5STACK_FIRE )
  #include "M5Stack.h"
#elif defined( ARDUINO_M5Stick_C )
  #include "M5StickC.h"
#endif

void setup() {
  M5.begin();
  M5.Lcd.fillScreen(RED);
}

void loop() {
}
anonymous No title
C++
#include <LGFX_TFT_eSPI.hpp>
#include "AXP192.h"
#include "utility/Config.h"
#include "utility/SH200Q.h"
#include "utility/MPU6886.h"
#include "utility/Button.h"
#include "utility/CommUtil.h"
#include "RTC.h"
#include "IMU.h"
 
#define BLACK               0x0000
#define NAVY                0x000F
#define DARKGREEN           0x03E0
#define DARKCYAN            0x03EF
#define MAROON              0x7800
#define PURPLE              0x780F
#define OLIVE               0x7BE0
#define LIGHTGREY           0xC618
#define DARKGREY            0x7BEF
#define BLUE                0x001F
#define GREEN               0x07E0
#define CYAN                0x07FF
#define RED                 0xF800
#define MAGENTA             0xF81F
#define YELLOW              0xFFE0
#define WHITE               0xFFFF
#define ORANGE              0xFD20
#define GREENYELLOW         0xAFE5
#define PINK                0xF81F
 
class M5StickCBoth {
  public:
    void begin(bool LCDEnable = true, bool PowerEnable = true, bool SerialEnable = true) {
      if (SerialEnable) {
        Serial.begin(115200);
        Serial.flush();
        delay(50);
        Serial.print("M5StickC initializing...");
      }
      if (PowerEnable) {
        Axp.begin();
      }
      if (LCDEnable) {
        Lcd.begin();
      }
      if (SerialEnable) {
        Serial.println("OK");
      }
      Rtc.begin();
    }
    void update() {
      BtnA.read();
      BtnB.read();
    }
    TFT_eSPI Lcd;
    AXP192 Axp = AXP192();
    const int DEBOUNCE_MS = 10;
    Button BtnA = Button(BUTTON_A_PIN, true, DEBOUNCE_MS);
    Button BtnB = Button(BUTTON_B_PIN, true, DEBOUNCE_MS);
    RTC  Rtc;
    IMU Imu;
    CommUtil I2C = CommUtil();
    MPU6886 Mpu6886;
    SH200Q Sh200Q;
};
 
static M5StickCBoth M5;
 
void setup() {
  M5.begin();
}
 
void loop() {
  M5.Lcd.fillScreen(WHITE);
  delay(1000);
  M5.Lcd.fillScreen(BLACK);
  delay(1000);
}
anonymous No title
C++
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <stdlib.h>
using namespace std;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}
int main(int argc,char** argv,char** envp){
    string input = string("../data/") + argv[1] + ".csv";
    ifstream inputfs(input);
    if(!inputfs.fail()){
        string str;
        while(getline(inputfs,str)){
            cout << str << endl;
        }
        return 0;
    }
    ifstream tagfs("../data/tag.csv");
    ifstream geotagfs("../data/geotag.csv");
    string tag_line,geotag_line;
    
    if(tagfs.fail()){
        cerr << "Failed to open tag.csv" << endl;
        return -1;
    }
    if(geotagfs.fail()){
        cerr << "Failed to open geotag.csv" << endl;
    }
    cout << "file open" << endl;
    //list<string> result;
    vector<string> result;
    result.reserve(10000);
    while(getline(tagfs,tag_line)){
        //todo
        vector<string> tag_sp = split(tag_line,',');
        string tag_id = tag_sp[0];
        string tag = tag_sp[1];
        if(tag==argv[1]){
            cout << "pie" << endl;
            while (getline(geotagfs,geotag_line)){
                vector<string> geotag_sp = split(geotag_line,',');
                string geotag_id = geotag_sp[0];
                if(tag_id==geotag_id){
                    
                    string data = geotag_line.substr(11);
                    cout << data << endl;
                    result.push_back(data);//Segmentaion Fault
                    break;
                }
            }
        }
    }
    cout << "poyo" << endl;
    sort(result.begin(),result.end());
    //result.sort();
    ofstream ofs(input);
    if(ofs.fail()){
        cout << "fout.open failed" << endl;
        return -1;
    }
    for(auto itr = result.begin();itr !=result.end();++itr){
        cout << *itr << endl;
        ofs << *itr << endl;
    }
    
}


anonymous No title
C++
#include <bits/stdc++.h>

using namespace std;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    // 二次元配列
    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (s[i] == s[j] && i != j) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
            ans = max(ans, dp[i + 1][j + 1]);
        }
    }

    string ans_string;
    int x = n, y = n;
    while (x > 0 && y > 0) {
        if (dp[x][y] == dp[x - 1][y]) {
            x--;
        } else if (dp[x][y] == dp[x][y - 1]) {
            y--;
        } else {
            x--, y--;
            ans_string = s[x] + ans_string;
        }
    }
    cout << ans_string << '\n';
    cout << ans << '\n';
}

int main() {
    solve();
    return 0;
}
Don't you submit code?
Submit