用c語言道歉
Ⅰ c語言中#error怎麼用
因為你的所有地方都沒定義 PI ,所以直接執行了#error First include then compile 這段。你把上面的條件改為#if 0 就可以運行了。
Ⅱ 用c語言怎麼打出 * ** *** ****
#include<stdio.h>
intmain()
{
for(inti=0;i<4;i++)
{
for(intj=0;j<i+1;j++)
printf("*");
printf("");
}
printf(" ");
return0;
}
Ⅲ 如何用c語言寫個道歉的程序求教
printf(%s,"對不起,我不是故意的。。。。");
Ⅳ 用C語言怎麼做
提問者需要把你需要解決的問題寫出來,然後根據問題來設定演算法,用C語言的規范書寫程序,經過編譯程序的編譯和運行以後,就能夠得到答案。
Ⅳ 如何用c語言寫個道歉的程序求教
內容是什麼呢?說下內容 如果我有時間幫你寫個簡單的
Ⅵ 怎樣用C語言編程解決這個問題
我碼了5個小時……看來我還是不熟練啊……
而且這些還沒有涉及到文件的輸入與輸出……
#include<stdio.h>
#include<string.h>
struct Student
{
int number=0;//學生的學號
char name[50];//學生的姓名
float ChineseScore, MathScore, EnglishScore, ComputerScore;//語文、數學、英語、計算機成績
};
Student Scorelist[100];
int i = 0;//i是Scorelist數組的下標序號,0<i<99
int main()
{
void Enter(Student Scorelist[]);
void Show(Student Scorelist[]);
void Search(Student Scorelist[]);
void Modify(Student Scorelist[]);
void Arrange(Student Scorelist[]);
void Count(Student Scorelist[]);
printf("接下來的操作是:\n");
printf("A.錄入瀏覽 B.查詢 C.修改 D.排序 E.統計 F.結束\n");
char answer1;
rewind(stdin);
answer1=getchar();
if (answer1 == 'A' || answer1 == 'a')
{
Enter(Scorelist);
Show(Scorelist);
return main();
}
else if (answer1 == 'B' || answer1 == 'b')
{
Search(Scorelist);
return main();
}
else if (answer1 == 'C' || answer1 == 'c')
{
Modify(Scorelist);
return main();
}
else if (answer1 == 'D' || answer1 == 'd')
{
Arrange(Scorelist);
return main();
}
else if (answer1 == 'E' || answer1 == 'e')
{
Count(Scorelist);
return main();
}
else if (answer1 == 'F' || answer1 == 'f')
{
return 0;
}
else
{
printf("輸入錯誤!\n");
printf("\n");
return main();
}
}
void Enter(Student Scorelist[])
{
for (; i < 100; i++)
{
printf("確定要錄入第%d個學生的信息嗎?請輸入Y(是)/N(否)\n", i + 1);
char answer2;
rewind(stdin);
answer2=getchar();
if (answer2 == 'N' || answer2 == 'n')
{
printf("\n");
return;
}
printf("請輸入學生的學號:");
scanf_s("%d", &Scorelist[i].number);
rewind(stdin);
printf("請輸入學生的姓名:");
gets_s(Scorelist[i].name,50);
printf("請輸入學生的語文成績:");
scanf_s("%f", &Scorelist[i].ChineseScore);
printf("請輸入學生的數學成績:");
scanf_s("%f", &Scorelist[i].MathScore);
printf("請輸入學生的英語成績:");
scanf_s("%f", &Scorelist[i].EnglishScore);
printf("請輸入學生的計算機成績:");
scanf_s("%f", &Scorelist[i].ComputerScore);
}
}
void Show(Student Scorelist[])
{
if (Scorelist[0].number == 0)
{
printf("無錄入信息!\n");
printf("\n");
return;
}
int j;
for (j = 0; j <= i-1; j++)
{
printf("學生的學號:%d\n", Scorelist[j].number);
printf("學生的姓名:%s\n", Scorelist[j].name);
printf("學生的語文成績:%f\n", Scorelist[j].ChineseScore);
printf("學生的數學成績:%f\n", Scorelist[j].MathScore);
printf("學生的英語成績:%f\n", Scorelist[j].EnglishScore);
printf("學生的計算機成績:%f\n", Scorelist[j].ComputerScore);
printf("\n");
}
printf("以上錄入的學生的全部信息。\n");
printf("\n");
}
void Search(Student Scorelist[])
{
printf("\n");
if (Scorelist[0].number == 0)
{
printf("無錄入信息!\n");
printf("\n");
return;
}
int j, a;
for (j = 0,a = 1; j <= i-1; j++)
{
if (Scorelist[j].number % 100 == 9)
{
printf("第%d個尾號為09的學生的學號:%d\n", a, Scorelist[j].number);
printf("第%d個尾號為09的學生的姓名:%s\n", a, Scorelist[j].name);
printf("第%d個尾號為09的學生的語文成績:%f\n", a, Scorelist[j].ChineseScore);
printf("第%d個尾號為09的學生的數學成績:%f\n", a, Scorelist[j].MathScore);
printf("第%d個尾號為09的學生的英語成績:%f\n", a, Scorelist[j].EnglishScore);
printf("第%d個尾號為09的學生的計算機成績:%f\n", a, Scorelist[j].ComputerScore);
printf("\n");
a++;
}
}
printf("以上為尾號為09的學生的全部信息。\n");
printf("\n");
}
void Modify(Student Scorelist[])
{
printf("\n");
if (Scorelist[0].number == 0)
{
printf("無錄入信息!\n");
printf("\n");
return;
}
int j, order;
int p[100];
for (j = 0, order = 1; j <= i-1; j++)
{
if (Scorelist[j].number % 100 == 12)
{
printf("第%d個尾號為12的學生的學號:%d\n", order, Scorelist[j].number);
printf("第%d個尾號為12的學生的姓名:%s\n", order, Scorelist[j].name);
printf("第%d個尾號為12的學生的語文成績:%f\n", order, Scorelist[j].ChineseScore);
printf("第%d個尾號為12的學生的數學成績:%f\n", order, Scorelist[j].MathScore);
printf("第%d個尾號為12的學生的英語成績:%f\n", order, Scorelist[j].EnglishScore);
printf("第%d個尾號為12的學生的計算機成績:%f\n", order, Scorelist[j].ComputerScore);
p[order] = j;
printf("\n");
order++;
}
}
printf("要修改哪一位尾號為12的學生的成績(請輸入上述順序中的數字序號):");
int ordernumber;
scanf_s("%d", &ordernumber);
printf("\n");
char answer3;
while(1)
{
printf("要修改該學生的成績嗎?請輸入Y(是)/N(否)\n");
rewind(stdin);
answer3 = getchar();
if (answer3 == 'N' || answer3 == 'n')
break;
printf("要修改該學生的哪一門成績?\n");
printf("A.語文 B.數學 C.英語 D.計算機\n");
rewind(stdin);
answer3 = getchar();
if (answer3 == 'A' || answer3 == 'a')
{
printf("該學生新的語文成績為:");
scanf_s("%f", &Scorelist[p[ordernumber]].ChineseScore);
}
else if (answer3 == 'B' || answer3 == 'b')
{
printf("該學生新的數學成績為:");
scanf_s("%f", &Scorelist[p[ordernumber]].MathScore);
}
else if (answer3 == 'C' || answer3 == 'c')
{
printf("該學生新的英語成績為:");
scanf_s("%f", &Scorelist[p[ordernumber]].EnglishScore);
}
else if (answer3 == 'D' || answer3 == 'd')
{
printf("該學生新的計算機成績為:");
scanf_s("%f", &Scorelist[p[ordernumber]].ComputerScore);
}
printf("\n");
printf("學生的學號:%d\n", Scorelist[p[ordernumber]].number);
printf("學生的姓名:%s\n", Scorelist[p[ordernumber]].name);
printf("學生的語文成績:%f\n", Scorelist[p[ordernumber]].ChineseScore);
printf("學生的數學成績:%f\n", Scorelist[p[ordernumber]].MathScore);
printf("學生的英語成績:%f\n", Scorelist[p[ordernumber]].EnglishScore);
printf("學生的計算機成績:%f\n", Scorelist[p[ordernumber]].ComputerScore);
printf("\n");
}
}
void Arrange(Student Scorelist[])
{
printf("\n");
if (Scorelist[0].number == 0)
{
printf("無錄入信息!\n");
printf("\n");
return;
}
Student temp;//Student類型變數temp用來存放每次比對得到的語文成績最高分的Student數組Scorelist中的元素
int number;//number用來存放每次比對得到的語文成績最高分的Student數組Scorelist中的元素d的下標序號
int m, n;//m為待整理Student數組p的下標序號,n為一輪比對最大值中每一次得到的Student數組Scorelist的下標序號
for (m = 0; m <= i-1; m++)
{
temp = Scorelist[m];
number = m;
for (n = m; n <= i-1; n++)
{
if (temp.ChineseScore < Scorelist[n].ChineseScore)
{
temp = Scorelist[n];
number = n;
}
}
Scorelist[number] = Scorelist[m];//不是最大值的,待整理的Student數組p中的元素換給每次比對得到的語文成績最高分的Student數組p中的元素
Scorelist[m] = temp;//每次比對得到的語文成績最高分的Student數組p中的元素換給不是最大值的,待整理的Student數組p中的元素
}
Show(Scorelist);
}
void Count(Student Scorelist[])
{
printf("\n");
if (Scorelist[0].number == 0)
{
printf("無錄入信息!\n");
printf("\n");
return;
}
int j;
for (j = 0; j <= i-1; j++)
{
printf("學生的學號:%d\n", Scorelist[j].number);
printf("學生的姓名:%s\n", Scorelist[j].name);
printf("學生的平均成績成績:%f\n", (Scorelist[j].ChineseScore + Scorelist[j].MathScore + Scorelist[j].EnglishScore + Scorelist[j].ComputerScore) / 4.0);
printf("\n");
}
printf("以上錄入的學生的全部信息。\n");
printf("\n");
}
Ⅶ 這個用C語言怎麼做
#include<stdio.h>
int main()
{
int max=0,min=0,aver=0;
int a[11];
int *p=a;//定義指針變數p,並指向數組a的首地址
for(;p<a+10;p++)
scanf("%d",p);//利用指針偏移,向數組中輸入10個整型數據
max=min=a[0];
for(p=a;p<a+10;p++)
if(*p>max)
max=*p;//記錄最大值
else if(*p<min)
min=*p;//記錄最小值
for(p=a;p<a+1;p++)
aver+=*p;//累加求和
aver/=10;//除以10求平均數
printf("max=%d,min=%d ",max,min);
for(p=a;p<a+10;p++)
if(*p>aver)
printf("%d ",*p);//輸出大於平均數的數組元素
return 0;
}