2019年807程序综合设计答案解析
//如有錯誤請及時通知我改正,我會第一時間在博客上更新,避免誤人子弟
//20190922
//#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
//1.C?
//2.D
//void main() {
//?? ?int a = -1, b = -1;
//?? ?if ((a >= 0 || b >= 0) && (a < 0 || b < 0)) {
//?? ??? ?printf("A\n");
//?? ?}
//?? ?if ((a >= 0 && b >= 0) && (a < 0 && b < 0)) {
//?? ??? ?printf("B\n");
//?? ?}
//?? ?if ((a+b>0) && (a+b<=0)) {
//?? ??? ?printf("C\n");
//?? ?}
//?? ?if (a*b>0) {
//?? ??? ?printf("D\n");
//?? ?}
//}
//int main() {
//?? ?int a = -1;
//?? ?int b = -1;
//?? ?//if (a*b > 0)
//?? ?if ((a>=0||b>=0)&&(a<0||b<0))
//?? ??? ?printf("T");
//?? ?else
//?? ??? ?printf("F");
//?? ?return 0;
//}
//3.A
//int fun(int x) {
//?? ?return x;
//}
//int main() {
//?? ?float a = 3.14;
//?? ?a = fun(a);
//?? ?//printf(".2%f\n",a);//我得出這個.23.000000//原題有誤
//?? ?printf("%.2f\n", a);//改正后
//?? ?return 0;
//}
//4.C
//int main() {
//?? ?static int s[2][4] = {0,1,2,3,4,5,6,7};
//?? ?int a, *p;
//?? ?p = &s[0][1];
//?? ?a = (*p)*(*p + 3)*(*p + 5);
//?? ?printf("%d\n",a);
//}
//5.B
//6.C
//數(shù)組規(guī)格是3行4列,所以如果3行2列是指a[3][2],那么就越界了。另外,BD會引發(fā)異常
//void main() {
//?? ?int a[3][4]= {?
//?? ??? ?0,1,2,3,
//?? ??? ?4,5,6,7,
//?? ??? ?8,9,10,11};//數(shù)學(xué)上的3行2列是9, a[2][1]
//
//?? ?scanf("%d",a[3,2]);//實際上它改變的是a[2][0],這個奇葩經(jīng)過我的驗證等價于a[2]
//?? ?printf("A:%d\n", a[2][1]);
//?? ?for (int i = 0; i < 3; i++) {
//?? ??? ?for (int j = 0; j < 4; j++) {
//?? ??? ??? ?printf("%4d ", a[i][j]);
//?? ??? ??? ?if (j == 3) {
//?? ??? ??? ??? ?printf("\n");
//?? ??? ??? ?}
//?? ??? ?}
//?? ?}
//
//?? ?//scanf("%d", *(*(a + 2) + 1));//Exception thrown,Access violation
//?? ?//printf("B:%d\n",a[2][1]);
//
//?? ?scanf("%d", *(a + 2) + 1);
//?? ?printf("C:%d\n", a[2][1]);
//?? ?for (int i = 0; i < 3; i++) {
//?? ??? ?for (int j = 0; j < 4; j++) {
//?? ??? ??? ?printf("%4d ", a[i][j]);
//?? ??? ??? ?if (j == 3) {
//?? ??? ??? ??? ?printf("\n");
//?? ??? ??? ?}
//?? ??? ?}
//?? ?}
//
//?? ?//scanf("%d", *(a[2] + 1));//Exception!!!!!!!!!!
//?? ?//printf("D:%d\n", a[2][1]);
//}
//7.A
//int main() {
//?? ?int a[4] = {0,1,2,3};
//?? ?int (*p)[4];//int *p[4]; int **p[4]; int p[4];
//?? ?p = a;
//?? ?printf("%X\n",**p);
//?? ?return 0;
//}
//8.D
//struct person {
//?? ?char name[9];
//?? ?int age;
//};
//int main() {
//?? ?struct person class[10] = {
//?? ?"Johu",17,"Paul",19,"Mary",18,"Adam",16
//?? ?};
//?? ?printf("%c\n",class[3].name);//隨機(jī)的
//?? ?printf("%c\n", class[3].name[1]);
//?? ?printf("%c\n", class[2].name[1]);
//?? ?printf("%c\n", class[2].name[0]);
//?? ?return 0;
//}
//9.A
//struct node{
//?? ?int data;
//?? ?struct node* next;
//};
//void main(){
//?? ?struct node E;
//?? ?struct node F;
//?? ?struct node G;
//?? ?struct node* p;
//?? ?struct node* s;
//?? ?struct node* y;
//?? ?E.data=11;
//?? ?F.data=22;
//?? ?G.data=33;
//?? ?p=&E;
//?? ?s=&G;
//?? ?y=&E;
//?? ?E.next=&F;
//?? ?F.next=NULL;
//?? ?//A
//?? ?//p=p->next;s->next=p;p->next=s;
//?? ?//B
//?? ?//p=p->next;s->next=p->next;p->next=s;
//?? ?//C
//?? ?//s->next=NULL;p=p->next;p->next=s;
//?? ?//D
//?? ?//p=(*p).next;(*s).next=(*p).next;(*p).next=s;
//
//?? ?printf("E.data==%d\n",y->data);
//?? ?printf("F.data==%d\n",y->next->data);
//?? ?if(y->next->next->next==NULL){
//?? ??? ?printf("G.data==%d\n", y->next->next->data);
//?? ??? ?printf("G.next==NULL\n");
//?? ?}else{
//?? ??? ?printf("G.data==%d\n", y->next->next->data);
//?? ??? ?printf("G.next!=NULL\n");//說明是錯的,單向鏈表末尾要指向NULL
//?? ?}
//}
//10.B
//11.T
//12.F
//13.F
//14.T
//15.F//
//16.F//
//int func(int a) {
//?? ?return a + 1;
//}
//int main() {
//?? ?float a = 2.0f;
//?? ?int b;
//?? ?a = func(a);
//?? ?printf("%d\n", a);
//}
//17.T
//18.F ///指向無參函數(shù)的指針
//19.F
//20.F
//21.
//struct person {
//?? ?char name[20];
//?? ?int age;
//}man[3];
//int main() {
//?? ?int i, key = 0;
//?? ?struct person *p,*q;
//?? ?for (i = 0; i < 3; i++)
//?? ??? ?scanf("%s %d",man[i].name,&man[i].age);
//?? ?for (p = man; p < man + 3; p++) {
//?? ??? ?if (p->age > key) {
//?? ??? ??? ?q = p;
//?? ??? ??? ?key = p->age;
//?? ??? ?}
//?? ?}
//?? ?printf("%s,%d\n",q->name,q->age);
//}
//22.
//#include<string.h>
//int main() {
//?? ?char str1[100], str2[100];
//?? ?char *p1,*p2;
//?? ?int k, j, i, len;
//
//?? ?p1 = str1;
//?? ?p2 = str2;
//?? ?scanf("%s",p1);
//?? ?scanf("%s",p2);
//?? ?k = j = i = 0;
//?? ?len = strlen(str2);
//?? ?while (p2[k] != '\0' && p1[j] != '\0') {
//?? ??? ?if (p1[k] == p2[j]) {
//?? ??? ??? ?k++;
//?? ??? ??? ?j++;
//?? ??? ?}
//?? ??? ?else {
//?? ??? ??? ?i++;
//?? ??? ??? ?k = i;
//?? ??? ??? ?j = 0;
//?? ??? ?}
//?? ?}
//?? ?if (j > len)
//?? ??? ?printf("Yes!\n");
//?? ?else?
//?? ??? ?printf("No!\n");
//?? ?return 0;
//}
//NO!
//NO!
//吐槽:貌似是跟子串有關(guān)
//23.
//int main() {
//?? ?char str[80];
//?? ?int i = 0;
//
//?? ?gets(str);
//?? ?while (str[i] != '\0') {
//?? ??? ?if (str[i] >= 'a' && str[i] <= 'z')
//?? ??? ??? ?a[i] = a[i] + 'A' - 'a';
//?? ??? ?else if (str[i] >= 'A' && str[i] <= 'Z')
//?? ??? ??? ?a[i] = a[i] + 'a' - 'A';
//?? ??? ?i++;
//?? ?}
//?? ?printf("%s\n", str);
//?? ?return 0;
//}
//結(jié)果:輸出 ? tHIS IS A TEST OF c pROGRAM lANGUAGE
//功能:輸入一個字符串,判斷每個字符大小寫,并將大寫換小寫,小寫換大寫
//題目有誤! a[i]改str[i]
//吐槽:懷疑出題老師太自信了,直接用word寫的代碼
//int main() {
//?? ?char str[80];
//?? ?int i = 0;
//
//?? ?gets(str);
//?? ?while (str[i] != '\0') {
//?? ??? ?if (str[i] >= 'a' && str[i] <= 'z')
//?? ??? ??? ?str[i] = str[i] + 'A' - 'a';
//?? ??? ?else if (str[i] >= 'A' && str[i] <= 'Z')
//?? ??? ??? ?str[i] = str[i] + 'a' - 'A';
//?? ??? ?i++;
//?? ?}
//?? ?printf("%s\n", str);
//?? ?return 0;
//}
//24.
//#define M 4
//#define N 5
//int fun(int (*b)[5]) {
//?? ?//int b[M][N];
//?? ?int sum=0;
//?? ?for (int i = 0;i<M; i++) {
//?? ??? ?for (int j = 0;j<N; j++) {
//?? ??? ??? ?if (i == 0 || i==M-1||j==0||j==N-1) {
//?? ??? ??? ??? ?sum += b[i][j];
//?? ??? ??? ??? ?continue;
//?? ??? ??? ?}
//?? ??? ?}
//?? ?}
//?? ?printf("%d",sum);
//?? ?return sum;
//}
//int main() {
//?? ?int a[M][N];
//?? ?// = {1,3,5,7,9,
//?? ?/*2, 9, 9, 9, 4,
//?? ??? ?6, 9, 9, 9, 8,
//?? ??? ?1, 3, 5, 7, 0
//}*/
//?? ?int temp;
//?? ?for (int i = 0;i<M; i++) {
//?? ??? ?for (int j = 0; j < N; j++) {
//?? ??? ??? ?printf("row %d,column %d\n",i,j);
//?? ??? ??? ?scanf("%d", &(a[i][j]));
//?? ??? ?}
//?? ?}
//?? ?fun(a);
//?? ?return 0;
//}
//25.
//#define N 4
//struct Student{
//?? ?int id;
//?? ?int math;
//?? ?int c;
//};
//
//int main() {
//?? ?struct Student s[N];
//?? ?printf("please input info\n");
//?? ?for (int i = 0; i < N; i++) {
//?? ??? ?printf("id\n");
//?? ??? ?scanf("%d",&(s[i].id));
//?? ??? ?printf("math\n");
//?? ??? ?scanf("%d", &(s[i].math));
//?? ??? ?printf("c\n");
//?? ??? ?scanf("%d", &(s[i].c));
//?? ?}
//?? ?/*for (int i = 0; i < N; i++) {
//?? ??? ?printf("id %d ,math %d ,c %d\n",s[i].id, s[i].math, s[i].c);
//?? ?}*/
//?? ?int MaxScore = 0;
//?? ?for (int i = 0; i < N; i++) {
//?? ??? ?if (s[i].c > MaxScore)
//?? ??? ??? ?MaxScore = s[i].c;
//?? ?}
//?? ?int sum = 0;
//?? ?for (int i = 0; i < N; i++) {
//?? ??? ?if (s[i].c == MaxScore) {
//?? ??? ??? ?printf("id %d ,math %d ,c %d\n", s[i].id, s[i].math, s[i].c);
//?? ??? ??? ?sum++;
//?? ??? ?}
//?? ?}
//?? ?printf("total: %d\n",sum);
//?? ?return 0;
//}
//26.
//這道題意思應(yīng)該是輸入10個字符串,然后用strcmp函數(shù)來排序,strcpy復(fù)制交換字符串
//strcmp(const char *s1, const char * s2);
//兩個字符串自左向右逐個字符相比(按ASCII值大小相比較),直到出現(xiàn)不同的字符或遇'\0'為止。如:
//"A"<"B" "a">"A" "computer" > "compare"
//https://blog.csdn.net/henuhhd/article/details/79368929
//思路:定義一個二維數(shù)組來保存10個字符串,用strcmp函數(shù)進(jìn)行兩次冒泡排序并輸出,一次升序,一次降序。
//#define M 10
//#define N 20
//
//void Sort(char s[][N], int style){
//?? ?char temp[N] = { 0 };
//?? ?for(int i=0;i<M;i++){
//?? ??? ?for(int j=0;j<M-i-1;j++){
//?? ??? ??? ?if (style == 0 && strcmp(s[j], s[j + 1])<0 ||
//?? ??? ??? ??? ?style == 1 && strcmp(s[j], s[j + 1])>0) {
//?? ??? ??? ??? ?strcpy(temp, s[j]);
//?? ??? ??? ??? ?strcpy(s[j], s[j + 1]);
//?? ??? ??? ??? ?strcpy(s[j+1], temp);
//?? ??? ??? ?}
//?? ??? ?}
//?? ?}
//}
//
//void main(){
//?? ?char s[M][N];
//?? ?//char s[M][N] = {"jfytdtd","gdgxr","gdtdc",};
//?? ?printf("please input 10 strings\n");
//?? ?for(int i=0;i<M;i++){
//?? ??? ?gets(s[i]);
//?? ?}
//?? ?Sort(s,0);
//?? ?for(int i=0;i<M;i++){
//?? ??? ?printf("style0: %s\n",s[i]);
//?? ?}
//?? ?printf("\n");
//?? ?Sort(s,1);
//?? ?for(int i=0;i<M;i++){
//?? ??? ?printf("style1: %s\n",s[i]);
//?? ?}
//}
?
總結(jié)
以上是生活随笔為你收集整理的2019年807程序综合设计答案解析的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开发直播软件必须要用直播系统源码才行
- 下一篇: 用计算机咋在电脑打字,怎样用电脑快速打字