考试错误练习
Posted yuzhenghan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了考试错误练习相关的知识,希望对你有一定的参考价值。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(){
int a;
int b;
int tmp;
int i;
printf("input a and b:");
scanf("%d%d", &a, &b);
if (a<b){
tmp = a;
a = b;
b = tmp;
}
for (i = a; i>0; i++){
if (i%a == 0 && i%b == 0){
printf("%d", i);
break;
}
}
system("pause");
return 0;}
#include<stdio.h>
#include<stdlib.h>
int cnt = 0;
int fib(int n){
cnt++;
if (n == 0)
return 1;
else if (n == 1)
return 2;
else
return fib(n - 1) + fib(n - 2);
}
int main(){
fib(8);
printf("%d ", fib(8));
system("pause");
return 0;
}
#include<stdlib.h>
int cnt = 0;
int fib(int n){
cnt++;
if (n == 0)
return 1;
else if (n == 1)
return 2;
else
return fib(n - 1) + fib(n - 2);
}
int main(){
fib(8);
printf("%d ", fib(8));
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int a = 1;
void test(){
int a = 2;
a += 1;
}
int main(){
test();
printf("%d ", a);
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main(){//陷入死循环
int x = 1;
do{
printf("%2d ", x++);
} while (x--);
system("pause");
return 0;
}
#include<stdlib.h>
int a = 1;
void test(){
int a = 2;
a += 1;
}
int main(){
test();
printf("%d ", a);
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main(){//陷入死循环
int x = 1;
do{
printf("%2d ", x++);
} while (x--);
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include<stdlib.h>
void ReserveStr(char *arr, int start, int end)
{
char ch;
if (arr == NULL)
return;
while (start<end)
{
ch = arr[start];
arr[start] = arr[end];
arr[end] = ch;
start++;
end--;
}
}
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include<stdlib.h>
void ReserveStr(char *arr, int start, int end)
{
char ch;
if (arr == NULL)
return;
while (start<end)
{
ch = arr[start];
arr[start] = arr[end];
arr[end] = ch;
start++;
end--;
}
}
void ReserveWord(char *arr)
{
int start = 0;
int end = 0;
int len = strlen(arr);
if (arr == NULL)
return;
{
int start = 0;
int end = 0;
int len = strlen(arr);
if (arr == NULL)
return;
ReserveStr(arr, 0, len - 1);
while (start<len)
{
end = start;
if (arr[start] != ‘ ‘)
{
while (arr[end] != ‘ ‘&&arr[end] != ‘ ‘)
{
end++;
}
ReserveStr(arr, start, end - 1);
start = end;
}
else
{
start++;
}
while (start<len)
{
end = start;
if (arr[start] != ‘ ‘)
{
while (arr[end] != ‘ ‘&&arr[end] != ‘ ‘)
{
end++;
}
ReserveStr(arr, start, end - 1);
start = end;
}
else
{
start++;
}
}
}
}
int main()
{
char str[100];
gets(str);
ReserveWord(str);
printf("%s", str);
system("pause");
return 0;
}
{
char str[100];
gets(str);
ReserveWord(str);
printf("%s", str);
system("pause");
return 0;
}
以上是关于考试错误练习的主要内容,如果未能解决你的问题,请参考以下文章