#include int main()
#include #include int main()
執行結果:
執行結果:
請輸入一段文字:yfu
67t87y
輸入的文字字元數為:10
輸入的文字資訊是:yfu
67t8
此處換行符會被過濾掉,所以逐行讀取,手動新增endl。
#include #include #include using namespace std;
int main()
// char x;
// while( in >> x)
// else
in.seekg(ios::beg); //指標指向檔案頭
for(string s; getline(in, s);)
cout << endl;
in.close();
out.close();
return 0;
}
#include int main()
std::cin.ignore(100, '\n');
std::cout << "輸入任何字元結束" << std::endl;
std::cin.get();
}
#include int main()
if(result != -1000)
else
}float f2c(float num)
float c2f(float num)
手癢寫乙個蟒蛇的版本:
temper = input('請輸入溫度,形如【23.2 c】或者【23.2 f】')
temp_value, temp_type = temper.split(' ')
temp_value = float(temp_value)
temp_type = temp_type.upper()
print(temp_type, temp_value)
if (temp_type == 'c') :
result = str(round(temp_value*1.8 + 32, 2)) + '℉'
elif(temp_type == 'f') :
result = str(round((temp_value-32)/1.8, 2)) + '℃'
else:
result = none
print('輸入有誤')
print(result)
#include#include#include int main()
執行結果如下:
values: updates = 6, *p_updates = 6
addresses: &updates = 0x7ffd2f82ce0c, &p_updates = 0x7ffd2f82ce0c
可見,
對變數名對應位址取間接運算子
,相當與獲得變數名對應值
。
#include#include#include int main()
; char chararray[items] = ;
int *intptr = intarray;
char *charptr = chararray;
//顯示整形陣列的記憶體位址
std::cout << "整型陣列輸出:" << '\n';
for (int i = 0; i < items; i++)
//顯示位元組型陣列的記憶體位址和指針對列印的影響
std::cout << "字元型陣列輸出:" << '\n';
for (int i = 0; i < items; i++)
//測試運算
int *temp = intarray;
std::cout << *temp+1<< std::endl;
std::cout << *(temp+1) << std::endl;
return 0;
};
#include #include using namespace std;
int main()
cout << plist->length() << endl; //4個位元組,64位系統
for (int i = 0; i#include using namespace std;
struct student;
const int arsize = 16;
int main()
;int main()
cout << "跳出選擇\n";
}cout << "跳出迴圈\n";
return 0;
}
#include #include #include using namespace std;
int main()
; int count{};
cout << "請輸入你需要的字元,用*結尾" << endl;
getline(cin, input, '*');
count = static_cast(input.length());
cout << "字元個數為:" << input << endl;
}
筆記之零碎點
1 include 2 3int main 4 1 include 2 include 3 4int main 5執行結果 5執行結果 請輸入一段文字 yfu 67t87y 輸入的文字字元數為 10 輸入的文字資訊是 yfu 67t8 此處換行符會被過濾掉,所以逐行讀取,手動新增endl。1 inc...
C 零碎筆記
1 編寫c 儲存為.cs檔案。2 通過csc.exe程式來將.cs檔案編譯為.net程式集 exe或.dll 是 偽exe 包含很多內容其中有微軟中間語言il可以被翻譯成類似彙編的中間碼 此時的exe或dll並不是機器碼 cpu不可理解 csc out c a.exe c program.cs 3 ...
Python零碎筆記
魔法方法 在python中,有一些內建好的特定的方法,這些方法在進行特定的操作時會自動被呼叫,稱之為魔法方法。常見的魔法方法有 init 初始化函式,在建立例項物件為其賦值時使用,必須至少有乙個引數self。new 建構函式,建立並返回乙個例項物件。必須要有返回值,返回例項化出來的例項。class ...