返回列表 發帖
#include<iostream>
#include<cstdlib>
using namespace std;

int main()
{
    string name="洪承廷,school=瑞興國小" ;
    int age=11;
    float w=145,x=35.5;
   
    cout<<"我的大名:"<<name<<endl;
    cout<<"我的學校:"<<school<<endl;
    cout<<"我的年齡:"<<age<<"歲"<<endl;
    cout<<"我的體重:"<<x<<"公斤"<<endl;
    cout<<"我的身高:"<<w<<"公分"<<endl;
    system("pause");
    return 0;

TOP

#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main()
{
   string str;
   int r;
   cout<<"請輸入一任意英文字串:";
   getline(cin,str);
   cout<<"想讓電腦幫你抓出第幾個字母?"<<endl;
   cin>>r;
   cout<<"字串的第"<<r<<"個字母為:"<<str[r-1]<<endl;
   system("pause");
   return 0;
}

TOP

[img]#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main()
{
   string str;
   int r;
   cout<<"請輸入一任意英文字串:";
   getline(cin,str);
   cout<<"想讓電腦幫你抓出第幾個字母?"<<endl;
   cin>>r;
   cout<<"字串的第"<<r<<"個字母為:"<<str[r-1]<<endl;
   system("pause");
   return 0;
}[/img]

TOP

#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int main()
{
   string str;
   int r;
   cout<<"請輸入一任意英文字串:";
   getline(cin,str);
   cout<<"想讓電腦幫你抓出第幾個字母?"<<endl;
   cin>>r;
   cout<<"字串的第"<<r<<"個字母為:"<<str[r-1]<<endl;
   system("pause");
   return 0;
}

TOP

返回列表