#include <stdio.h> #include <math.h> // #define precision double typedef double precision; // #define TOP 20000 // KEAZ128 // #define TOP 8000 // KL25 #define TOP (38400 * 0.8) // EFR32P12 #define STEP 50 const precision Pi2 = (2 * M_PI); const precision NE = (1 / M_E); const precision amplitude = (TOP / (M_E - (1 / M_E))); int main(void) { precision out; precision i; printf("\nNE = %f, amplitude = %f\n", NE, amplitude); printf("sin(π/2) = %f\n", sin(M_PI / 2)); int j; for(j = 0, i = 0; i < Pi2; i += 0.1, j++) { if( (j & 0x07) == 0 ) printf("\n"); out = (exp(sin(i)) - NE) * amplitude; printf("%d,\t", (int)out); } printf("\n"); }
#include <iostream> using namespace std; int getNumber(bool &check) { check = !check; return check ? 10 : 20; } int main() { bool numero = false; cout << getNumber(numero) << endl; cout << getNumber(numero) << endl; cout << getNumber(numero) << endl; } //https://pt.stackoverflow.com/q/45723/101
#include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; }
#include <iostream> using namespace std; int main() { int ***ptr; ptr = (int ***)malloc(5*sizeof(int**)); for(int i=0;i<5;i++){ *(ptr+i) = (int**)malloc(5*sizeof(int*)); for(int j=0;j<5;j++){ *(*(ptr+i)+j) = (int*)malloc(5*sizeof(int)); } } int n=0; for(int i =0;i<5;i++){ for(int j=0;j<5;j++){ for(int k=0;k<5;k++){ *(*(*(ptr+i)+j)+k) = ++n; } } } printf("%d\n",*(*(*(ptr+1)+2)+4)); printf("%d\n",ptr[1][2][4]); return 0; }
#include <iostream> #include <map> int main() { std::map<int, std::string> m{ {10, "10"}, {20, "20"}, {30, "30"}, {40, "40"}, {50, "50"} }; std::cout << "lower bound 25: " << m.lower_bound(25)->second << std::endl; std::cout << "upper bound 25: " << m.upper_bound(25)->second << std::endl; std::cout << "lower bound 30: " << m.lower_bound(30)->second << std::endl; std::cout << "upper bound 30: " << m.upper_bound(30)->second << std::endl; return 0; }
Unable to open file!