c在線編程
#include<stdio.h>//頭文件補上
int max(int x,int y)//定義聲明函數
{
int z;
z=(x>y)?x:y;
return(z);
}
int main()
{
int a,b,c;
scanf("%d,%d",&a,&b);
c=max(a,b);//函數調用
printf("%d",c);
return 0;
}
Ⅱ C語言簡單編程 在線等
意思是在熒幕上顯示hello,world。有一處錯誤,括弧內要加引號,另外,要執行的話需要先編譯才行
Ⅲ 有什麼好的C語言在線編程網站嗎
南洋理工學院的OJ系統還是不錯的,希望對你有幫助,望採納
Ⅳ C語言編程,在線著急等
#include "stdio.h"
#include <stdlib.h>
#define N 5
int prime(int n){//質數判斷
int i;
if(n>2 && !(n&1) || n<2)
return 0;
for(i=3;i*i<=n;i+=2)
if(!(n%i))
return 0;
return 1;
}
int main(int argc,char *argv[]){
int a[N],i,k;
printf("Please enter %d positive integer(s)... ",N);
for(k=i=0;i<N;i++){//輸入數據
if(scanf("%d",a+i)==1 && a[i]>0)
k+=a[i];
else{//若輸入小於0則重新輸入
printf("Input error, redo: ");
i--;
fflush(stdin);
}
}
printf(" The AVERAGE is %g Prime Numbers are as follows: ",k/20.0);//輸出平均值
for(k=i=0;i<N;i++)//輸入質數
if(prime(a[i]))
printf(++k%3 ? "%11d" : "%11d ",a[i]);
if(k==0)
printf("No find prime Numbers... ");
else if(k%3)
printf(" ");
return 0;
}
運行樣例:
Ⅳ 跪求c語言在線編程網站
不如用WINTC才不到10MB
Ⅵ C語言編程在線等
main()
{
float a,b;
char ch;
scanf("%f%c%f",&a,&ch,&b);
switch(ch){
case '+':{printf("=%f",a+b);break;}
case '-':{printf("=%f",a-b);break;}
case '*':{printf("=%f",a*b);break;}
case '/':{printf("=%f",a/b);break;}
default:break;
}
getch();
}
Ⅶ 能實現輸入函數的C/C++在線編譯器
我認為目前最好用的在線編譯器; http://www.mcqyy.com/RunCode/cpp/
Ⅷ C語言編程 在線等
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#defineN100
structscore
{
floatmath;
floatenglish;
floatcomputer;
};
structstudent
{
intnumber;
charname[20];
structscoresco;
floataverage;
};
structstudentstu[N];
floatinput_score(int);//計算學生平均成績
voidprint_student2(void);//顯示表頭
voidprint_student3(int);//顯示學生信息
voidprint_student1(int);//顯示全部學生資料
voidprint_student1(inta)//顯示全部學生資料
{
printf("本班所有學生具體信息如下 ");
print_student2();
for(inti=0;i<a;i++)
{
print_student3(i);
}
}
voidprint_student3(inta)//顯示學生信息
{
printf("%8d%12s%14.2f%14.2f%14.2f%14.2f ",stu[a].number,stu[a].name,stu[a].sco.math,stu[a].sco.english,stu[a].sco.computer,stu[a].average);
}
voidprint_student2(void)//顯示表頭
{
printf("學號姓名數學成績英語成績計算機成績平均成績 ");
}
voidinput_student1(inta)//輸入學生信息
{
printf("學號:");
scanf("%d",&stu[a].number);
getchar();
printf("姓名:");
gets(stu[a].name);
printf("數學成績:");
scanf("%f",&stu[a].sco.math);
printf("英語成績:");
scanf("%f",&stu[a].sco.english);
printf("計算機成績:");
scanf("%f",&stu[a].sco.computer);
}
floatinput_score(inta)//計算學生平均成績
{
return(stu[a].sco.math+stu[a].sco.english+stu[a].sco.computer)/3;
}
//voidmain()
intmain()
//最好是intmain
{
structstudentstu[N];
input_score(student);
print_student2(student);
print_student3(student);
print_student1(student);
print_student1(student);
return0;
//加上返回值
}
Ⅸ C語言編程在線求解。
#include <stdio.h>
int main()
{
int a[5][5]={{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20},{21,22,23,24,25}};
int i,j,s1=0,s2=0,s3=0;
for(i=0;i<5;i++)
s1=s1+a[i][i];
for(i=0,j=4;i<5,j>=0;j--,i++)
s2+=a[i][j];
for(i=0;i<5;i++)
s3=a[0][i]+s3;
for(i=1;i<4;i++)
s3=a[i][0]+s3+a[i][4];
for(i=0;i<5;i++)
s3=a[4][i]+s3;
printf("s1=%d,s2=%d,s3=%d\n",s1,s2,s3);
}
Ⅹ 在線c語言編程高手
#include <stdio.h>
int main()
{
float price=-1, last_price=-1;
int cnt = 0, total = 0;
int increase_flag = 0;
while(~scanf("%f", &price))
{
total++;
printf("%d\t%7.3f", total, price);
if(cnt > 2)
printf("\t%s", increase_flag ? "sell" : "buy");
printf("\n");
if(last_price != -1)
{
if(price > last_price)
{
if(increase_flag) cnt ++;
else increase_flag = 1, cnt = 1;
}
else if(price < last_price)
{
if(!increase_flag) cnt ++;
else increase_flag = 0, cnt = 1;
}
else cnt++;
}
last_price = price;
}
return 0;
}
part3的
#include <stdio.h>
int main()
{
float price=-1, last_price=-1;
int cnt = 0, total = 0;
int increase_flag = 0;
float cash = 10000, shares = 0;
printf("period price cash shares value\n");
printf("-----------------------------------------------\n");
while(~scanf("%f", &price))
{
total++;
if(cnt > 2)
{
if(increase_flag)
{
if(shares != 0)
{
cash = shares * price;
shares = 0;
}
}
else
{
if(cash != 0)
{
shares = cash / price;
cash = 0;
}
}
}
printf(" %3d \t%7.3f\t%10.2f\t%7.2f\t%10.2f\n", total, price, cash, shares, cash+shares * price);
if(last_price != -1)
{
if(price > last_price)
{
if(increase_flag) cnt ++;
else increase_flag = 1, cnt = 1;
}
else if(price < last_price)
{
if(!increase_flag) cnt ++;
else increase_flag = 0, cnt = 1;
}
else cnt++;
}
last_price = price;
}
return 0;
}