《大学院受験機試験》(一)C/C++基礎
3153 ワード
1.setfill/setw使用
2.構造体の定義
3.文字列読み出しについて
4.並べ替え問題:再試行は一般用を要求しない:泡立ち並べ替え
5.数字と文字の変換
6.進数変換:10進数から8進数へ
7.素数判断
8.文字列コピー関数strcpy
9.文字列結合関数strcat
10.文字列比較関数strcmp
11.文字列長関数strlenの計算
補足内容:
本文:
2.構造体の定義
3.文字列読み出しについて
4.並べ替え問題:再試行は一般用を要求しない:泡立ち並べ替え
5.数字と文字の変換
6.進数変換:10進数から8進数へ
7.素数判断
8.文字列コピー関数strcpy
9.文字列結合関数strcat
10.文字列比較関数strcmp
11.文字列長関数strlenの計算
補足内容:
:
for(int i=0; ia[j+1]){
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
:
int left = 0;
int right = len - 1;
int mid;
while( left<=right){
mid = left + (right - left)/2;//
if(find_data == a[mid]){
return mid;
}else if(find_data > a[mid]){
left = mid + 1;
}else{
right = mid - 1;
}
}
return -1;//
:
, ,
1. min,
2. , min , 2
3. 2
for(int i=0; ia[j]){
min = a[j];
minIndex = j;//
}
}
// ,
if(min!=a[i]){
a[minIndex] = a[i];
a[i] = min;
}
}
:
void insertSort(int a[], int n){
for(int i=1; i=0 && temp
本文:
#include
#include
#include
#include
using namespace std;
int main(void){
// 1.setfill/setw
// float f1 = 2.99;
// float f2 = 8.9099;
// int i = 10;
// cout << setfill('*');
// //setw ,
// // ,
// //setfill
// // , iomanip
// cout << setw(10) << f1 << endl;
// cout << setw(10) << f2 << endl;
// cout << setw(10) << i << endl;
// 2.
// struct Student{
// int id;
// char name[20];
// };
// typedef
// typedef struct Student{
// int id;
// char name[20];
// }Student;
//
// :Student s;
// 3.
// string str = "hello gy";
// int i = 0;
// while(str[i] != '\0'){
// cout << str[i] << endl;
// i++;
// }
// 4.
// :
// int len = 6;
// int num[] = {5,2,77,1,99,66};
// for(int i=0; inum[j+1] ){
// int temp = num[j];
// num[j] = num[j+1];
// num[j+1] = temp;
// }
// }
// }
// for(int i=0; i=0; i--){
// cout << result[i] <s2 0;s1