提交 4f3dfc42 编写于 作者: M Martin Aeschlimann

[c] colorizer tests

上级 0f32c8e9
/* C Program to find roots of a quadratic equation when coefficients are entered by user. */
/* Library function sqrt() computes the square root. */
#include <stdio.h>
#include <math.h> /* This is needed to use sqrt() function.*/
int main()
{
float a, b, c, determinant, r1,r2, real, imag;
printf("Enter coefficients a, b and c: ");
scanf("%f%f%f",&a,&b,&c);
determinant=b*b-4*a*c;
if (determinant>0)
{
r1= (-b+sqrt(determinant))/(2*a);
r2= (-b-sqrt(determinant))/(2*a);
printf("Roots are: %.2f and %.2f",r1 , r2);
}
else if (determinant==0)
{
r1 = r2 = -b/(2*a);
printf("Roots are: %.2f and %.2f", r1, r2);
}
else
{
real= -b/(2*a);
imag = sqrt(-determinant)/(2*a);
printf("Roots are: %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag);
}
return 0;
}
\ No newline at end of file
#if B4G_DEBUG_CHECK
fprintf(stderr,"num_candidate_ret=%d:", num_candidate);
for(int i=0;i<num_candidate;++i)
fprintf(stderr,"%d,",user_candidate[i]);
fprintf(stderr,";");
#endif
void main(O obj) {
LOG_INFO("not hilighted as string");
LOG_INFO(obj << ", even worse; " << obj.x << " check this out.");
// everything from this point on is interpeted as a string literal...
O x;
std::unique_ptr<O> o(new O);
// sadness.
sprintf(options, "STYLE=Keramik;TITLE=%s;THEME=%s", ...);
}
int main2() {
printf(";");
// the rest of
asm("movw $0x38, %ax; ltr %ax");
fn("{};");
// the rest of
}
\ No newline at end of file
// classes example
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int,int);
int area() {return width*height;}
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
int main () {
Rectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册