标签:getc float else guess 最大数 return char printf mat
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
float a, b, c, x1, x2;
float delta, real, imag;
printf("Enter a, b, c: ");
while(scanf("%f%f%f", &a, &b, &c)) {
if(a == 0)
printf("not quadratic equation.\n");
else {
delta = b*b - 4*a*c;
if(delta >= 0) {
x1 = (-b + sqrt(delta)) / (2*a);
x2 = (-b - sqrt(delta)) / (2*a);
printf("x1 = %f, x2 = %f\n", x1, x2);
}
else {
real = -b/(2*a);
imag = sqrt(-delta) / (2*a);
printf("x1 = %f + %fi, x2 = %f - %fi\n", real, imag, real, imag);
}
}
printf("Enter a, b, c:\n");
}
system("pause");
return 0;
}
#include <stdio.h>
#include <math.h>
int isprime(int n);
int main(){
int x;
int m;
for(x=101,m=0;x<=200;x++)
{
if(isprime(x))
{
printf("%4d",x);
m++;
if(m%5==0)
printf("\n");
}
}
printf("\n");
printf("101~200之间有%d个素数",m);
return 0;
}
int isprime(int n)
{
int k;
for(k=2;k<=sqrt(n);k++)
if(n%k==0)
return 0;
return 1;
}
#include <stdio.h>
int main(){
int c;
printf("Enter a number\n");
while((c=getchar())!=‘\n‘)
{
switch(c%2)
{
case 0:continue;
case 1:putchar(c);break;
}
}
return 0;
}
标签:getc float else guess 最大数 return char printf mat
原文地址:https://www.cnblogs.com/kkdy/p/11885722.html